public class BasicTaskWrapper extends java.lang.Object implements TaskWrapper
| Modifier and Type | Field and Description |
|---|---|
private long |
completionTimeout
The completion timeout
|
private static org.jboss.logging.Logger |
log
The log
|
private int |
priority
The priority
|
private java.lang.Thread |
runThread
The thread
|
private long |
startTime
The start time
|
private long |
startTimeout
The start timeout
|
private int |
state
The state of the task
|
private java.lang.Object |
stateLock
The state lock
|
private Task |
task
The task
|
static int |
TASK_ACCEPTED
The task has been accepted
|
static int |
TASK_COMPLETED
The task has completed
|
static int |
TASK_NOT_ACCEPTED
The task has not been accepted
|
static int |
TASK_REJECTED
The task was rejected
|
static int |
TASK_STARTED
The task has been started
|
static int |
TASK_STOPPED
The task has been stopped
|
private java.lang.String |
taskString
The task as a string
|
private int |
waitType
The wait type
|
| Modifier | Constructor and Description |
|---|---|
protected |
BasicTaskWrapper()
Create a task wrapper without a task
|
|
BasicTaskWrapper(Task task)
Create a new task wrapper
|
| Modifier and Type | Method and Description |
|---|---|
void |
acceptTask()
The task has been accepted
|
protected long |
getElapsedTime()
Calculate the elapsed time since the task was started
|
protected java.lang.String |
getStateString()
Get the state as a string
|
long |
getTaskCompletionTimeout()
The time before the task must be completed
|
int |
getTaskPriority()
The priority of the task
|
long |
getTaskStartTimeout()
The time before the task must be accepted
|
int |
getTaskWaitType()
Get the type of wait
|
boolean |
isComplete()
Is the task complete.
|
void |
rejectTask(java.lang.RuntimeException e)
The task has been rejected
|
void |
run()
Called by the thread pool executor
|
protected void |
setTask(Task task)
Set thetask for this wrapper
|
void |
stopTask()
Invoked by the threadpool when it wants to stop the task
|
protected boolean |
taskAccepted()
Notify the task it has been accepted
|
protected boolean |
taskCompleted(java.lang.Throwable throwable)
Notify the task it has completed
|
protected boolean |
taskRejected(java.lang.RuntimeException e)
Notify the task it has been rejected
|
protected boolean |
taskStarted()
Notify the task it has started
|
protected boolean |
taskStop()
Stop the task
|
void |
waitForTask()
Wait according the wait type
|
private static final org.jboss.logging.Logger log
public static final int TASK_NOT_ACCEPTED
public static final int TASK_ACCEPTED
public static final int TASK_STARTED
public static final int TASK_COMPLETED
public static final int TASK_REJECTED
public static final int TASK_STOPPED
private int state
private java.lang.Object stateLock
private Task task
private java.lang.String taskString
private long startTime
private long startTimeout
private long completionTimeout
private int priority
private int waitType
private java.lang.Thread runThread
protected BasicTaskWrapper()
public BasicTaskWrapper(Task task)
task - the taskjava.lang.IllegalArgumentException - for a null taskpublic int getTaskWaitType()
TaskWrappergetTaskWaitType in interface TaskWrapperpublic int getTaskPriority()
TaskWrappergetTaskPriority in interface TaskWrapperpublic long getTaskStartTimeout()
TaskWrappergetTaskStartTimeout in interface TaskWrapperpublic long getTaskCompletionTimeout()
TaskWrappergetTaskCompletionTimeout in interface TaskWrapperpublic void acceptTask()
TaskWrapperacceptTask in interface TaskWrapperpublic void rejectTask(java.lang.RuntimeException e)
TaskWrapperrejectTask in interface TaskWrappere - any error associated with the rejectionpublic boolean isComplete()
TaskWrapperisComplete in interface TaskWrapperpublic void stopTask()
TaskWrapperstopTask in interface TaskWrapperpublic void waitForTask()
TaskWrapperwaitForTask in interface TaskWrapperpublic void run()
run in interface java.lang.Runnableprotected void setTask(Task task)
task - the taskprotected boolean taskAccepted()
protected boolean taskRejected(java.lang.RuntimeException e)
e - any error associated with the rejectionprotected boolean taskStarted()
protected boolean taskCompleted(java.lang.Throwable throwable)
throwable - any throwable associated with the completionprotected boolean taskStop()
protected long getElapsedTime()
protected java.lang.String getStateString()