com.sun.enterprise.web.connector.grizzly
Class AsyncReadTask

java.lang.Object
  extended by com.sun.enterprise.web.connector.grizzly.TaskBase
      extended by com.sun.enterprise.web.connector.grizzly.DefaultReadTask
          extended by com.sun.enterprise.web.connector.grizzly.AsyncReadTask
All Implemented Interfaces:
ReadTask, Task, TaskListener, Runnable, Callable

public class AsyncReadTask
extends DefaultReadTask

This task execute and then notify its listener, which usualy execute on their own thread. The task perform the same operation as its parent, but the attached ProcessorTask execute on its own thread.

Author:
Jean-Francois Arcand

Field Summary
 
Fields inherited from class com.sun.enterprise.web.connector.grizzly.DefaultReadTask
algorithm, byteBuffer, bytesAvailable, inputStream, maxPostSize, processorTask, taskContext, taskEvent, useByteBufferView, useDirectByteBuffer
 
Fields inherited from class com.sun.enterprise.web.connector.grizzly.TaskBase
key, listeners, pipeline, recycle, selectorThread, type
 
Fields inherited from interface com.sun.enterprise.web.connector.grizzly.Task
ACCEPT_TASK, PROCESSOR_TASK, READ_TASK
 
Constructor Summary
AsyncReadTask()
           
 
Method Summary
 void configureProcessorTask()
          Set appropriate attribute on the ProcessorTask.
 void doTask()
          Read data from the socket and process it using this thread, and only if the StreamAlgorith stategy determine no more bytes are are needed.
 boolean executeProcessorTask()
          Execute the ProcessorTask
 void initialize(StreamAlgorithm algorithm, boolean useDirectByteBuffer, boolean useByteBufferView)
           
protected  void manageKeepAlive(boolean keepAlive, int count, Exception exception)
          Manage the SelectionKey
 void recycle()
          Clear the current state and make this object ready for another request.
 void setByteBuffer(ByteBuffer srcBB)
          Set the underlying ByteBuffer used by this class.
 void terminate(boolean keepAlive)
          Complete the transaction.
 
Methods inherited from class com.sun.enterprise.web.connector.grizzly.DefaultReadTask
attachProcessor, detachProcessor, doTask, finishConnection, getByteBuffer, getIdleTime, getProcessorTask, registerKey, returnTask, setBytesAvailable, setIdleTime, taskEvent
 
Methods inherited from class com.sun.enterprise.web.connector.grizzly.TaskBase
addTaskListener, call, cancelTask, clearTaskListeners, execute, fireTaskEvent, getKeepAliveStats, getPipeline, getRecycle, getRequestGroupInfo, getSelectionKey, getSelectorThread, getSocket, getTaskListeners, getType, isMonitoringEnabled, removeTaskListener, run, setPipeline, setRecycle, setSelectionKey, setSelectorThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.enterprise.web.connector.grizzly.Task
addTaskListener, cancelTask, clearTaskListeners, execute, getKeepAliveStats, getPipeline, getRecycle, getRequestGroupInfo, getSelectionKey, getSelectorThread, getTaskListeners, getType, isMonitoringEnabled, removeTaskListener, setPipeline, setRecycle, setSelectionKey, setSelectorThread
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface java.util.concurrent.Callable
call
 

Constructor Detail

AsyncReadTask

public AsyncReadTask()
Method Detail

initialize

public void initialize(StreamAlgorithm algorithm,
                       boolean useDirectByteBuffer,
                       boolean useByteBufferView)
Specified by:
initialize in interface ReadTask
Overrides:
initialize in class DefaultReadTask

doTask

public void doTask()
            throws IOException
Read data from the socket and process it using this thread, and only if the StreamAlgorith stategy determine no more bytes are are needed.

Specified by:
doTask in interface Task
Overrides:
doTask in class DefaultReadTask
Throws:
IOException

manageKeepAlive

protected void manageKeepAlive(boolean keepAlive,
                               int count,
                               Exception exception)
Manage the SelectionKey

Overrides:
manageKeepAlive in class DefaultReadTask

executeProcessorTask

public boolean executeProcessorTask()
                             throws IOException
Execute the ProcessorTask

Overrides:
executeProcessorTask in class DefaultReadTask
Returns:
false if the request wasn't fully read by the channel. so we need to respin the key on the Selector.
Throws:
IOException

recycle

public void recycle()
Clear the current state and make this object ready for another request.

Specified by:
recycle in interface Task
Overrides:
recycle in class DefaultReadTask

setByteBuffer

public void setByteBuffer(ByteBuffer srcBB)
Set the underlying ByteBuffer used by this class.

Overrides:
setByteBuffer in class DefaultReadTask

terminate

public void terminate(boolean keepAlive)
Complete the transaction.

Specified by:
terminate in interface ReadTask
Overrides:
terminate in class DefaultReadTask

configureProcessorTask

public void configureProcessorTask()
Set appropriate attribute on the ProcessorTask.

Overrides:
configureProcessorTask in class DefaultReadTask


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.