|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.http.TaskBase
com.sun.grizzly.http.ProcessorTask
public class ProcessorTask
Process HTTP request. This class is based on
com.sun.grizzly.tcp.http11.Http11Processor
Nested Class Summary | |
---|---|
static interface |
ProcessorTask.PostProcessor
|
Field Summary | |
---|---|
protected Adapter |
adapter
Associated adapter. |
protected boolean |
aptCancelKey
True if AsyncProtocolFilter should cancel the selectionkey in the terminateProcess() call |
protected boolean |
asyncExecution
Is asynchronous mode enabled? |
protected AsyncHandler |
asyncHandler
When the asynchronous mode is enabled, the execution of this object will be delegated to the AsyncHandler |
protected boolean |
bufferResponse
Buffer the response until the buffer is full. |
protected String[] |
compressableMimeTypes
List of MIMES which could be gzipped |
protected int |
compressionLevel
Allowed compression level. |
protected int |
compressionMinSize
Minimum contentsize to make compression. |
protected boolean |
connectionHeaderValueSet
Connection: value |
protected boolean |
contentDelimitation
Content delimitator for the request (if false, the connection will be closed at the end of the request). |
protected String |
defaultResponseType
The default response-type |
protected boolean |
disableUploadTimeout
Flag to disable setting a different time-out on uploads. |
protected boolean |
dropConnection
Allow client of this class to force connection closing. |
protected boolean |
error
Error flag. |
protected String |
forcedRequestType
The forced request-type |
protected boolean |
handleKeepAliveBlockingThread
|
protected boolean |
hasRequestInfoRegistered
Has the request associated with this ProcessorTask been
registered with the RequestGroupInfo |
protected char[] |
hostNameC
Host name (used to avoid useless B2C conversion on the host name). |
protected boolean |
http09
HTTP/0.9 flag. |
protected boolean |
http11
HTTP/1.1 flag. |
protected InternalInputBuffer |
inputBuffer
Input. |
protected InputStream |
inputStream
Input Stream. |
protected boolean |
isAsyncHttpWriteEnabled
Flag, which indicates if async HTTP write is enabled |
protected boolean |
keepAlive
Keep-alive. |
protected int |
keepAliveLeft
The current keep-alive count left before closing the connection. |
protected String |
localAddr
The local Host address. |
protected String |
localName
Local Host associated with the current connection. |
protected int |
localPort
Local port to which the socket is connected |
protected int |
maxHttpHeaderSize
Default HTTP header buffer size. |
protected int |
maxKeepAliveRequests
Max keep-alive request before timing out. |
protected int |
maxPostSize
Max post size. |
protected String[] |
noCompressionUserAgents
List of user agents to not use gzip with |
protected ObjectName |
oname
ObjectName under which this ProcessorTask will be
JMX-registered if monitoring has been turned on |
protected SocketChannelOutputBuffer |
outputBuffer
Output. |
protected OutputStream |
outputStream
Output Stream. |
protected String |
remoteAddr
Remote Address associated with the current connection. |
protected String |
remoteHost
Remote Host associated with the current connection. |
protected int |
remotePort
Remote port to which the socket is connected |
protected Request |
request
Request object. |
protected int |
requestBufferSize
The input request buffer size. |
protected static int |
requestCount
The number of requests ProcessorTask has proceeded. |
protected RequestInfo |
requestInfo
The code>RequestInfo used to gather stats. |
protected boolean |
reRegisterSelectionKey
False prevents the selectionkey from being re registered after async is done in the terminateProcess() call |
protected Response |
response
Response object. |
protected String[] |
restrictedUserAgents
List of restricted user agents. |
protected static StringManager |
sm
The string manager for this package. |
protected Socket |
socket
Socket associated with the current connection. |
protected SSLSupport |
sslSupport
SSL information. |
protected boolean |
started
State flag. |
protected StreamAlgorithm |
streamAlgorithm
The StreamAlgorithm used by this Task to manipulate the request. |
protected int |
uploadTimeout
Maximum uploadTimeout on uploads. |
Fields inherited from class com.sun.grizzly.http.TaskBase |
---|
key, selectorHandler, selectorThread, threadPool, type |
Fields inherited from interface com.sun.grizzly.http.Task |
---|
ACCEPT_TASK, PROCESSOR_TASK, READ_TASK |
Constructor Summary | |
---|---|
ProcessorTask()
|
|
ProcessorTask(boolean init)
|
|
ProcessorTask(boolean init,
boolean bufferResponse)
|
Method Summary | |
---|---|
void |
action(ActionCode actionCode,
Object param)
Send an action to the connector. |
void |
addCompressableMimeType(String mimeType)
Add a mime-type which will be compressable The mime-type String will be exactly matched in the response mime-type header . |
protected void |
addFilter(String className)
Add input or output filter. |
protected boolean |
addInputFilter(InputFilter[] inputFilters,
String encodingName)
Add an input filter to the current request. |
void |
addNoCompressionUserAgent(String userAgent)
Add user-agent for which gzip compression didn't works The user agent String given will be exactly matched to the user-agent header submitted by the client. |
void |
addRestrictedUserAgent(String userAgent)
Add restricted user-agent (which will downgrade the connector to HTTP/1.0 mode). |
protected void |
configPreProcess()
Prepare this object before parsing the request. |
protected Request |
createRequest()
Creates Request object. |
protected Response |
createResponse()
Creates Response object. |
protected OutputFilter |
detectCompression()
Check for compression. |
protected boolean |
doProcess()
Process an HTTP request using a non blocking Socket |
void |
doTask()
Execute the HTTP request by parsing the header/body, and then by delegating the process to the Catalina container. |
protected int |
findBytes(ByteChunk bc,
byte[] b)
Specialized utility method: find a sequence of lower case bytes inside a ByteChunk. |
String[] |
findCompressableMimeTypes()
Return the list of comprassable mime types. |
String[] |
findNoCompressionUserAgents()
Return the list of no compression user agents. |
String[] |
findRestrictedUserAgents()
Return the list of restricted user agents. |
void |
finishResponse()
Finish the response |
Adapter |
getAdapter()
Get the associated adapter. |
boolean |
getAptCancelKey()
True if AsyncProtocolFilter should cancel the selectionkey in the terminateProcess() call |
AsyncHandler |
getAsyncHandler()
Return the AsyncHandler used when asynchronous execution is
enabled. |
int |
getBufferSize()
Return the request input buffer size |
String |
getCompression()
Return compression level. |
int |
getCompressionMinSize()
|
String |
getDefaultResponseType()
Return the default response type used |
boolean |
getDisableUploadTimeout()
Get the flag that controls upload time-outs. |
boolean |
getDropConnection()
Is the keep-alive mechanism enabled or disabled. |
String |
getForcedRequestType()
Return the default request type used |
boolean |
getForceKeepAlive()
Is keep-alive forced? |
InputStream |
getInputStream()
|
int |
getMaxHttpHeaderSize()
|
int |
getMaxPostSize()
Return the maximum size of a POST which will be buffered in SSL mode. |
Request |
getRequest()
Return the internal Request object. |
String |
getRequestURI()
Get the request URI associated with this processor. |
boolean |
getReRegisterSelectionKey()
False prevents the selectionkey from being re registered after async is done in the terminateProcess() call. |
int |
getSendBufferSize()
|
SSLSupport |
getSSLSupport()
Return the SSLSupport object used by this instance. |
StreamAlgorithm |
getStreamAlgorithm()
Return the StreamAlgorithm used by this instance. |
int |
getTimeout()
Get the upload uploadTimeout. |
int |
getTransactionTimeout()
Set the maximum time, in milliseconds, a WorkerThread executing
an instance of this class can execute. |
long |
getWorkerThreadID()
Return the current WorkerThread ID associated with this instance. |
boolean |
hasNextRequest()
|
void |
initialize()
Initialize the stream and the buffer used to parse the request. |
protected void |
initializeFilters()
Initialize standard input and output filters. |
void |
invokeAdapter()
Invoke the Adapter , which usualy invoke the Servlet
Container. |
boolean |
isAsyncExecutionEnabled()
Is asynchronous execution enabled? |
boolean |
isAsyncHttpWriteEnabled()
Is async HTTP write enabled. |
boolean |
isError()
|
boolean |
isInitialized()
Returns true, if ProcessorTask was initialized, or false otherwise. |
boolean |
isKeepAlive()
|
boolean |
isSkipPostExecute()
returns value and resets it to false. |
boolean |
isUseChunking()
Is chunking encoding used. |
protected OutputFilter |
lookupCompressionFilter(MessageBytes encoding)
|
protected String |
messageDropConnection(int status)
|
void |
parseHost(MessageBytes valueMB)
Parse host. |
boolean |
parseRequest()
Parse the request line and the http header. |
void |
postProcess()
Post process the http request, after the response has been commited. |
void |
postResponse()
Prepare and post the response. |
void |
prepareForNextRequest()
|
protected void |
prepareRequest()
After reading the request headers, we have to setup the request filters. |
protected void |
prepareResponse()
When committing the response, we have to validate the set of headers, as well as setup the response filters. |
void |
preProcess()
Pre process the request by decoding the request line and the header. |
void |
preProcess(InputStream input,
OutputStream output)
Pre process the request by decoding the request line and the header. |
boolean |
process(InputStream input,
OutputStream output)
Process pipelined HTTP requests using the specified input and output streams. |
void |
recycle()
Recycle this object. |
void |
setAdapter(Adapter adapter)
Set the associated adapter. |
void |
setAptCancelKey(boolean aptCancelKey)
True if AsyncProtocolFilter should cancel the selectionkey in the terminateProcess() call |
void |
setAsyncHandler(AsyncHandler asyncHandler)
Set the AsyncHandler used when asynchronous execution is
enabled. |
void |
setAsyncHttpWriteEnabled(boolean isAsyncHttpWriteEnabled)
Set if async HTTP write enabled. |
void |
setBufferSize(int requestBufferSize)
Set the request input buffer size |
void |
setCompressableMimeType(String[] compressableMimeTypes)
Set compressable mime-type list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array). |
void |
setCompressableMimeTypes(String compressableMimeTypes)
Set compressable mime-type list List contains users agents separated by ',' : ie: "text/html,text/xml,text/plain" |
void |
setCompressableMimeTypes(String[] compressableMimeTypes)
Set compressable mime-type list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array). |
void |
setCompression(String compression)
Set compression level. |
void |
setCompressionMinSize(int compressionMinSize)
|
void |
setConnectionHeaderValueSet(boolean connectionHeaderValueSet)
|
void |
setDefaultResponseType(String defaultResponseType)
Set the default response type used. |
void |
setDisableUploadTimeout(boolean isDisabled)
Set the flag to control upload time-outs. |
void |
setDropConnection(boolean dropConnection)
Enable or disable the keep-alive mechanism. |
void |
setEnableAsyncExecution(boolean asyncExecution)
Enable/disable asynchronous execution of this object. |
void |
setForcedRequestType(String forcedRequestType)
Sets the forced request type, which is forced onto requests that do not already specify any MIME type. |
void |
setForceKeepAlive(boolean forceKeepAlive)
Force keep-alive no mather what the client support. |
void |
setInputStream(InputStream inputStream)
|
void |
setMaxHttpHeaderSize(int maxHttpHeaderSize)
|
void |
setMaxPostSize(int mps)
Set the maximum size of a POST which will be buffered in SSL mode. |
void |
setNoCompressionUserAgents(String[] noCompressionUserAgents)
Set no compression user agent list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array). |
void |
setReRegisterSelectionKey(boolean reRegisterSelectionKey)
False prevents the selectionkey from being re registered after async is done in the terminateProcess() call. |
void |
setRestrictedUserAgents(String[] restrictedUserAgents)
Set restricted user agent list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array). |
void |
setSendBufferSize(int sendBufferSize)
|
void |
setSocket(Socket socket)
Set the socket associated with this HTTP connection. |
void |
setSSLSupport(SSLSupport sslSupport)
Set the SSLSupport object used by this instance. |
void |
setStreamAlgorithm(StreamAlgorithm streamAlgorithm)
Set the StreamAlgorithm used by this class. |
void |
setTimeout(int timeouts)
Set the upload uploadTimeout. |
void |
setTransactionTimeout(int transactionTimeout)
Set the maximum time, in milliseconds, a WorkerThread processing
an instance of this class. |
void |
setUseChunking(boolean useChunking)
Enable chunking the http response. |
protected boolean |
statusDropsConnection(int status)
Determine if we must drop the connection because of the HTTP status code. |
void |
terminateProcess()
Notify the TaskListener that the request has been
fully processed. |
protected void |
unregisterMonitoring()
Unregisters the MBean corresponding to this ProcessorTask . |
Methods inherited from class com.sun.grizzly.http.TaskBase |
---|
call, execute, execute, getSelectionKey, getSelectorHandler, getSelectorThread, getTaskListener, getThreadPool, getType, run, setSelectionKey, setSelectorHandler, setSelectorThread, setTaskListener, setThreadPool |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final StringManager sm
protected Adapter adapter
protected Request request
protected Response response
protected InternalInputBuffer inputBuffer
protected InputStream inputStream
protected OutputStream outputStream
protected SocketChannelOutputBuffer outputBuffer
protected boolean started
protected boolean error
protected boolean keepAlive
protected boolean connectionHeaderValueSet
protected boolean http11
protected boolean http09
protected boolean contentDelimitation
protected SSLSupport sslSupport
protected Socket socket
protected String remoteAddr
protected String remoteHost
protected String localName
protected int localPort
protected int remotePort
protected String localAddr
protected int uploadTimeout
protected int maxPostSize
protected char[] hostNameC
protected boolean hasRequestInfoRegistered
ProcessorTask
been
registered with the RequestGroupInfo
protected int maxHttpHeaderSize
protected static int requestCount
ProcessorTask
has proceeded.
protected int requestBufferSize
protected ObjectName oname
ProcessorTask
will be
JMX-registered if monitoring has been turned on
protected boolean dropConnection
protected int keepAliveLeft
protected StreamAlgorithm streamAlgorithm
StreamAlgorithm
used by this Task
to manipulate the request.
protected String defaultResponseType
protected String forcedRequestType
protected boolean asyncExecution
protected RequestInfo requestInfo
protected AsyncHandler asyncHandler
AsyncHandler
protected String[] noCompressionUserAgents
protected String[] compressableMimeTypes
protected int compressionLevel
protected int compressionMinSize
protected String[] restrictedUserAgents
protected boolean bufferResponse
protected boolean disableUploadTimeout
protected boolean isAsyncHttpWriteEnabled
protected int maxKeepAliveRequests
protected boolean handleKeepAliveBlockingThread
protected boolean reRegisterSelectionKey
protected boolean aptCancelKey
Constructor Detail |
---|
public ProcessorTask()
public ProcessorTask(boolean init)
public ProcessorTask(boolean init, boolean bufferResponse)
Method Detail |
---|
public void initialize()
protected Request createRequest()
Request
object.
Request
object.protected Response createResponse()
Response
object.
Response
object.public void doTask() throws IOException
doTask
in interface Task
IOException
public void preProcess() throws Exception
Exception
public void preProcess(InputStream input, OutputStream output) throws Exception
input
- the InputStream to read bytesoutput
- the OutputStream to write bytes
Exception
protected void configPreProcess() throws Exception
Exception
protected boolean doProcess() throws Exception
Socket
Exception
public boolean hasNextRequest()
public void postResponse() throws Exception
Exception
public void finishResponse()
public void invokeAdapter()
Adapter
, which usualy invoke the Servlet
Container.
public boolean parseRequest() throws Exception
Exception
public void postProcess() throws Exception
Exception
public void terminateProcess()
TaskListener
that the request has been
fully processed.
public boolean process(InputStream input, OutputStream output) throws Exception
process
in interface Processor
input
- stream from which the HTTP requests will be readoutput
- stream which will be used to output the HTTP
responses
Exception
- error during an I/O operationpublic String getRequestURI()
public void action(ActionCode actionCode, Object param)
action
in interface ActionHook
actionCode
- Type of the actionparam
- Action parameterpublic void setAdapter(Adapter adapter)
setAdapter
in interface Processor
adapter
- the new adapterpublic Adapter getAdapter()
getAdapter
in interface Processor
protected void prepareRequest()
public void parseHost(MessageBytes valueMB)
protected void prepareResponse()
protected void initializeFilters()
protected boolean addInputFilter(InputFilter[] inputFilters, String encodingName)
protected int findBytes(ByteChunk bc, byte[] b)
protected boolean statusDropsConnection(int status)
protected String messageDropConnection(int status)
protected void addFilter(String className)
className
- class name of the filterpublic void setMaxPostSize(int mps)
public int getMaxPostSize()
public void setSocket(Socket socket)
public void setTimeout(int timeouts)
public int getTimeout()
public boolean isAsyncHttpWriteEnabled()
public void setAsyncHttpWriteEnabled(boolean isAsyncHttpWriteEnabled)
isAsyncHttpWriteEnabled
- true, if async HTTP write
enabled, or false otherwise.protected void unregisterMonitoring()
ProcessorTask
.
public int getMaxHttpHeaderSize()
public void setMaxHttpHeaderSize(int maxHttpHeaderSize)
public void setBufferSize(int requestBufferSize)
public int getBufferSize()
public void setDropConnection(boolean dropConnection)
public boolean getDropConnection()
public void setStreamAlgorithm(StreamAlgorithm streamAlgorithm)
StreamAlgorithm
used by this class.
public StreamAlgorithm getStreamAlgorithm()
StreamAlgorithm
used by this instance.
public void setDefaultResponseType(String defaultResponseType)
public String getDefaultResponseType()
public void setForcedRequestType(String forcedRequestType)
public String getForcedRequestType()
public void setEnableAsyncExecution(boolean asyncExecution)
public boolean isAsyncExecutionEnabled()
public void setAsyncHandler(AsyncHandler asyncHandler)
AsyncHandler
used when asynchronous execution is
enabled.
public AsyncHandler getAsyncHandler()
AsyncHandler
used when asynchronous execution is
enabled.
public Request getRequest()
Request
object.
public void recycle()
recycle
in interface Task
recycle
in class TaskBase
public String getCompression()
public void setCompression(String compression)
public void addNoCompressionUserAgent(String userAgent)
userAgent
- user-agent stringpublic void setNoCompressionUserAgents(String[] noCompressionUserAgents)
public String[] findNoCompressionUserAgents()
public void addCompressableMimeType(String mimeType)
mimeType
- mime-type stringpublic void setCompressableMimeTypes(String[] compressableMimeTypes)
public void setCompressableMimeTypes(String compressableMimeTypes)
public void setCompressableMimeType(String[] compressableMimeTypes)
public String[] findCompressableMimeTypes()
protected OutputFilter detectCompression()
protected OutputFilter lookupCompressionFilter(MessageBytes encoding)
public int getCompressionMinSize()
public void setCompressionMinSize(int compressionMinSize)
public void addRestrictedUserAgent(String userAgent)
userAgent
- user-agent stringpublic void setRestrictedUserAgents(String[] restrictedUserAgents)
public String[] findRestrictedUserAgents()
public SSLSupport getSSLSupport()
public void setSSLSupport(SSLSupport sslSupport)
public long getWorkerThreadID()
public boolean isKeepAlive()
public void setConnectionHeaderValueSet(boolean connectionHeaderValueSet)
public boolean isError()
public InputStream getInputStream()
public void setInputStream(InputStream inputStream)
public void setDisableUploadTimeout(boolean isDisabled)
public boolean getDisableUploadTimeout()
public int getTransactionTimeout()
WorkerThread
executing
an instance of this class can execute.
public void setTransactionTimeout(int transactionTimeout)
WorkerThread
processing
an instance of this class.
transactionTimeout
- the maximum time, in milliseconds.public boolean isUseChunking()
public void setUseChunking(boolean useChunking)
useChunking
- public void setReRegisterSelectionKey(boolean reRegisterSelectionKey)
reRegisterSelectionKey
- public boolean getReRegisterSelectionKey()
public void setAptCancelKey(boolean aptCancelKey)
aptCancelKey
- public boolean getAptCancelKey()
public void setForceKeepAlive(boolean forceKeepAlive)
public boolean getForceKeepAlive()
public int getSendBufferSize()
public void setSendBufferSize(int sendBufferSize)
sendBufferSize
- the sendBufferSize to setpublic boolean isSkipPostExecute()
public boolean isInitialized()
public void prepareForNextRequest()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |