public class Task extends Object
Future that monitors it's work via log appenders specific for the
BroadWorksServer sessions in the taskServers list. Tasks also receive TaskEvents that are sent on the BroadWorksServers
within the taskServers list.
There is also support for a final task result message that can easily tell the user if the task was successful.| Constructor and Description |
|---|
Task(String name,
co.ecg.alpaca.toolkit.model.BroadWorksServer... broadWorksServers)
Creates a new Task with the provided name and backing BroadWorksServer list.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
close()
Closes the log appenders and unregisters this from the BroadWorksServer event buses.
|
void |
finish(String resultMessage)
Finishes the task with the provided result message.
|
String |
getName() |
TaskResult |
getResult() |
TaskStatus |
getStatus() |
List<String> |
getTaskLog() |
protected List<co.ecg.alpaca.toolkit.model.BroadWorksServer> |
getTaskServers() |
boolean |
isComplete()
Returns if the task thread has ran and completed.
|
void |
logToConsole(Alpaca alpaca)
Sends the Task events to the provided Alpaca console.
|
protected void |
postLogMessage(String logMessage)
Adds a log message for this task.
|
void |
setTask(Callable<Object> task)
Sets the
Callable to be performed by this task. |
protected Future |
start(ThreadPoolExecutor executorService)
Begins the task with the provided
ExecutorService |
void |
taskEvent(TaskEvent event) |
public Task(String name, co.ecg.alpaca.toolkit.model.BroadWorksServer... broadWorksServers)
name - The name of the task. This identifies the process to the user and should be unique.broadWorksServers - The varargs of backing BroadWorksServers for the task.protected Future start(ThreadPoolExecutor executorService)
ExecutorServiceexecutorService - The thread pool to run the Task upon.protected void close()
public void logToConsole(Alpaca alpaca)
alpaca - The alpaca console to log to.public boolean isComplete()
public TaskStatus getStatus()
public void setTask(Callable<Object> task)
Callable to be performed by this task.task - The Callablepublic String getName()
public void finish(String resultMessage)
resultMessage - The result message.public TaskResult getResult()
protected List<co.ecg.alpaca.toolkit.model.BroadWorksServer> getTaskServers()
protected void postLogMessage(String logMessage)
logMessage - The log message to add.public void taskEvent(TaskEvent event)
Copyright © 2016. All rights reserved.