站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

BasicTaskWrapper (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


org.jboss.util.threadpool
Class BasicTaskWrapper

java.lang.Object
  extended byorg.jboss.util.threadpool.BasicTaskWrapper
All Implemented Interfaces:
Runnable, TaskWrapper

public class BasicTaskWrapper
extends Object
implements TaskWrapper

A wrapper for the task.

Version:
$Revision: 1.1.8.1 $
Author:
Adrian Brock

Field Summary
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
 
Constructor Summary
protected BasicTaskWrapper()
          Create a task wrapper without a task
  BasicTaskWrapper(Task task)
          Create a new task wrapper
 
Method Summary
 void acceptTask()
          The task has been accepted
protected  long getElapsedTime()
          Calculate the elapsed time since the task was started
 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()
          Indicate if the task has exited the Runnable#run method
 void rejectTask(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(Throwable throwable)
          Notify the task it has completed
protected  boolean taskRejected(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TASK_NOT_ACCEPTED

public static final int TASK_NOT_ACCEPTED
The task has not been accepted

See Also:
Constant Field Values

TASK_ACCEPTED

public static final int TASK_ACCEPTED
The task has been accepted

See Also:
Constant Field Values

TASK_STARTED

public static final int TASK_STARTED
The task has been started

See Also:
Constant Field Values

TASK_COMPLETED

public static final int TASK_COMPLETED
The task has completed

See Also:
Constant Field Values

TASK_REJECTED

public static final int TASK_REJECTED
The task was rejected

See Also:
Constant Field Values

TASK_STOPPED

public static final int TASK_STOPPED
The task has been stopped

See Also:
Constant Field Values
Constructor Detail

BasicTaskWrapper

protected BasicTaskWrapper()
Create a task wrapper without a task


BasicTaskWrapper

public BasicTaskWrapper(Task task)
Create a new task wrapper

Parameters:
task - the task
Throws:
IllegalArgumentException - for a null task
Method Detail

getTaskWaitType

public int getTaskWaitType()
Description copied from interface: TaskWrapper
Get the type of wait

Specified by:
getTaskWaitType in interface TaskWrapper
Returns:
the wait type

getTaskPriority

public int getTaskPriority()
Description copied from interface: TaskWrapper
The priority of the task

Specified by:
getTaskPriority in interface TaskWrapper
Returns:
the task priority

getTaskStartTimeout

public long getTaskStartTimeout()
Description copied from interface: TaskWrapper
The time before the task must be accepted

Specified by:
getTaskStartTimeout in interface TaskWrapper
Returns:
the start timeout

getTaskCompletionTimeout

public long getTaskCompletionTimeout()
Description copied from interface: TaskWrapper
The time before the task must be completed

Specified by:
getTaskCompletionTimeout in interface TaskWrapper
Returns:
the completion timeout

acceptTask

public void acceptTask()
Description copied from interface: TaskWrapper
The task has been accepted

Specified by:
acceptTask in interface TaskWrapper

rejectTask

public void rejectTask(RuntimeException e)
Description copied from interface: TaskWrapper
The task has been rejected

Specified by:
rejectTask in interface TaskWrapper
Parameters:
e - any error associated with the rejection

isComplete

public boolean isComplete()
Description copied from interface: TaskWrapper
Indicate if the task has exited the Runnable#run method

Specified by:
isComplete in interface TaskWrapper
Returns:
true if the task has exited the Runnable#run method

stopTask

public void stopTask()
Description copied from interface: TaskWrapper
Invoked by the threadpool when it wants to stop the task

Specified by:
stopTask in interface TaskWrapper

waitForTask

public void waitForTask()
Description copied from interface: TaskWrapper
Wait according the wait type

Specified by:
waitForTask in interface TaskWrapper

run

public void run()
Called by the thread pool executor

Specified by:
run in interface Runnable

setTask

protected void setTask(Task task)
Set thetask for this wrapper

Parameters:
task - the task

taskAccepted

protected boolean taskAccepted()
Notify the task it has been accepted

Returns:
true when the notification succeeds, false otherwise

taskRejected

protected boolean taskRejected(RuntimeException e)
Notify the task it has been rejected

Parameters:
e - any error associated with the rejection
Returns:
true when the notification succeeds, false otherwise

taskStarted

protected boolean taskStarted()
Notify the task it has started

Returns:
true when the notification succeeds, false otherwise

taskCompleted

protected boolean taskCompleted(Throwable throwable)
Notify the task it has completed

Parameters:
throwable - any throwable associated with the completion
Returns:
true when the notification succeeds, false otherwise

taskStop

protected boolean taskStop()
Stop the task

Returns:
true when the notification succeeds, false otherwise

getElapsedTime

protected long getElapsedTime()
Calculate the elapsed time since the task was started

Returns:
the elapsed time in millis


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.