com.sun.enterprise.web.ara.algorithms
Class ContextRootAlgorithm

java.lang.Object
  extended by com.sun.enterprise.web.ara.algorithms.ContextRootAlgorithm
All Implemented Interfaces:
StreamAlgorithm

public class ContextRootAlgorithm
extends Object
implements StreamAlgorithm

Parse the request bytes and seek for the context-root value of the HTTP method.

Author:
Jeanfrancois Arcand

Constructor Summary
ContextRootAlgorithm()
           
 
Method Summary
 ByteBuffer allocate(boolean useDirect, boolean useView, int size)
          Allocate a ByteBuffer
 int contentLength()
          Return the stream content-length.
 Handler getHandler()
          Return null as handler aren't required.
 int getPort()
          Return the port
 Class getReadTask(SelectorThread selectorThread)
          Return the class responsible for handling OP_READ.
 int headerLength()
          Return the stream header length.
 boolean parse(ByteBuffer byteBuffer)
          Parse the request line in search of the context-root bytes of the HTTP Method.
 ByteBuffer postParse(ByteBuffer byteBuffer)
          After parsing the bytes, post process the ByteBuffer
 ByteBuffer preParse(ByteBuffer byteBuffer)
          Before parsing the bytes, initialize and prepare the algorithm.
 void recycle()
          Recycle the algorithm.
 ByteBuffer rollbackParseState(ByteBuffer byteBuffer)
          Rollback the ByteBuffer to its previous state in case an error as occured.
 void setPort(int port)
          Set the port
 void setSocketChannel(SocketChannel socketChannel)
          Set the SocketChannel used by this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextRootAlgorithm

public ContextRootAlgorithm()
Method Detail

allocate

public ByteBuffer allocate(boolean useDirect,
                           boolean useView,
                           int size)
Allocate a ByteBuffer

Specified by:
allocate in interface StreamAlgorithm
Parameters:
useDirect - allocate a direct ByteBuffer.
useView - allocate a view ByteBuffer.
size - the size of the newly created ByteBuffer.
Returns:
a new ByteBuffer

contentLength

public int contentLength()
Return the stream content-length. If the content-length wasn't parsed, return -1.

Specified by:
contentLength in interface StreamAlgorithm

headerLength

public int headerLength()
Return the stream header length. The header length is the length between the start of the stream and the first occurance of character '\r\n' .

Specified by:
headerLength in interface StreamAlgorithm

parse

public boolean parse(ByteBuffer byteBuffer)
Parse the request line in search of the context-root bytes of the HTTP Method. The ByteBuffer position and limit refer respectively to the start and the end of the context root.

Specified by:
parse in interface StreamAlgorithm
Parameters:
byteBuffer - The byteBuffer containing the requests bytes
Returns:
true if the context-root has been found.

postParse

public ByteBuffer postParse(ByteBuffer byteBuffer)
After parsing the bytes, post process the ByteBuffer

Specified by:
postParse in interface StreamAlgorithm
Parameters:
byteBuffer - the ByteBuffer used by this algorithm
Returns:
ByteBuffer used by this algorithm

preParse

public ByteBuffer preParse(ByteBuffer byteBuffer)
Before parsing the bytes, initialize and prepare the algorithm.

Specified by:
preParse in interface StreamAlgorithm
Parameters:
byteBuffer - the ByteBuffer used by this algorithm
Returns:
ByteBuffer used by this algorithm

recycle

public void recycle()
Recycle the algorithm.

Specified by:
recycle in interface StreamAlgorithm

rollbackParseState

public ByteBuffer rollbackParseState(ByteBuffer byteBuffer)
Rollback the ByteBuffer to its previous state in case an error as occured.

Specified by:
rollbackParseState in interface StreamAlgorithm

getReadTask

public Class getReadTask(SelectorThread selectorThread)
Return the class responsible for handling OP_READ.

Specified by:
getReadTask in interface StreamAlgorithm

setSocketChannel

public void setSocketChannel(SocketChannel socketChannel)
Set the SocketChannel used by this class.

Specified by:
setSocketChannel in interface StreamAlgorithm

getHandler

public Handler getHandler()
Return null as handler aren't required.

Specified by:
getHandler in interface StreamAlgorithm

setPort

public void setPort(int port)
Set the port

Specified by:
setPort in interface StreamAlgorithm

getPort

public int getPort()
Return the port

Specified by:
getPort in interface StreamAlgorithm


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