com.sun.grizzly.http
Class TaskBase

java.lang.Object
  extended by com.sun.grizzly.http.TaskBase
All Implemented Interfaces:
Task, Runnable, Callable
Direct Known Subclasses:
AsyncProcessorTask, ProcessorTask

public abstract class TaskBase
extends Object
implements Task

Abstract implementation of a Task object.

Author:
Jean-Francois Arcand

Field Summary
protected  SelectionKey key
          The SelectionKey used by this task.
protected  SelectorHandler selectorHandler
          SelectorHandler, which handles this SelectionKey I/O events
protected  SelectorThread selectorThread
          The SelectorThread who created this task.
protected  ExecutorService threadPool
          The ExecutorService object associated with this Task
protected  int type
          This number represent a specific implementation of a Task instance.
 
Fields inherited from interface com.sun.grizzly.http.Task
ACCEPT_TASK, PROCESSOR_TASK, READ_TASK
 
Constructor Summary
TaskBase()
           
 
Method Summary
 Object call()
          By default, do nothing when a Callable is invoked.
 void execute()
          Execute the task based on its ExecutorService.
 void execute(ExecutorService threadPool)
          Execute this task using the passed ExecutorService.
 SelectionKey getSelectionKey()
          Return the SelectionKey associated with this task.
 SelectorHandler getSelectorHandler()
          Returns SelectorHandler, which handles this taks's SelectionKey
 SelectorThread getSelectorThread()
          Return the SelectorThread
 TaskListener getTaskListener()
          The TaskListener associated with this instance.
 ExecutorService getThreadPool()
          Return the thread pool used by this object.
 int getType()
          Return this Tash type.
 void recycle()
          Recycle internal state.
 void run()
          Some ExecutorService implementation requires a instance of Runnable instance.
 void setSelectionKey(SelectionKey key)
          Set the SelectionKey
 void setSelectorHandler(SelectorHandler selectorHandler)
          Sets SelectorHandler, which handles this taks's SelectionKey
 void setSelectorThread(SelectorThread selectorThread)
          Set the SelectorThread object.
 void setTaskListener(TaskListener taskListener)
          Set the TaskListener associated with this class.
 void setThreadPool(ExecutorService threadPool)
          Set the thread pool on which Worker Threads will synchronize.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.grizzly.http.Task
doTask
 

Field Detail

type

protected int type
This number represent a specific implementation of a Task instance.


threadPool

protected ExecutorService threadPool
The ExecutorService object associated with this Task


key

protected SelectionKey key
The SelectionKey used by this task.


selectorThread

protected SelectorThread selectorThread
The SelectorThread who created this task.


selectorHandler

protected SelectorHandler selectorHandler
SelectorHandler, which handles this SelectionKey I/O events

Constructor Detail

TaskBase

public TaskBase()
Method Detail

getType

public int getType()
Description copied from interface: Task
Return this Tash type.

Specified by:
getType in interface Task

setSelectorThread

public void setSelectorThread(SelectorThread selectorThread)
Set the SelectorThread object.

Specified by:
setSelectorThread in interface Task

getSelectorThread

public SelectorThread getSelectorThread()
Return the SelectorThread

Specified by:
getSelectorThread in interface Task

getSelectorHandler

public SelectorHandler getSelectorHandler()
Returns SelectorHandler, which handles this taks's SelectionKey

Specified by:
getSelectorHandler in interface Task
Returns:
SelectorHandler, which handles this taks's SelectionKey

setSelectorHandler

public void setSelectorHandler(SelectorHandler selectorHandler)
Sets SelectorHandler, which handles this taks's SelectionKey

Specified by:
setSelectorHandler in interface Task

setThreadPool

public void setThreadPool(ExecutorService threadPool)
Set the thread pool on which Worker Threads will synchronize.

Specified by:
setThreadPool in interface Task

getThreadPool

public ExecutorService getThreadPool()
Return the thread pool used by this object.

Specified by:
getThreadPool in interface Task

setSelectionKey

public void setSelectionKey(SelectionKey key)
Set the SelectionKey

Specified by:
setSelectionKey in interface Task

getSelectionKey

public SelectionKey getSelectionKey()
Return the SelectionKey associated with this task.

Specified by:
getSelectionKey in interface Task

execute

public void execute()
Execute the task based on its ExecutorService. If the ExecutorService is null, then execute the task on using the calling thread.

Specified by:
execute in interface Task

execute

public void execute(ExecutorService threadPool)
Execute this task using the passed ExecutorService. If the ExecutorService is null, the task's doTask() method will be invoked.

Specified by:
execute in interface Task

recycle

public void recycle()
Recycle internal state.

Specified by:
recycle in interface Task

run

public void run()
Some ExecutorService implementation requires a instance of Runnable instance.

Specified by:
run in interface Runnable

call

public Object call()
            throws Exception
By default, do nothing when a Callable is invoked.

Specified by:
call in interface Callable
Throws:
Exception

getTaskListener

public TaskListener getTaskListener()
The TaskListener associated with this instance.

Returns:
TaskListener associated with this instance.

setTaskListener

public void setTaskListener(TaskListener taskListener)
Set the TaskListener associated with this class.

Parameters:
{@link - TaskListener} associated with this instance.


Copyright © 2012 Oracle Corporation. All Rights Reserved.