Fields Summary |
---|
protected com.sun.enterprise.web.connector.grizzly.TaskContext | taskContextThe taskContext associated with this object. The
taskContext contains information about the current
connection. |
protected com.sun.enterprise.web.connector.grizzly.TaskEvent | taskEventThe TaskEvent associated with this task. |
private int | requestBufferSizeNot used right since AsyncWeb has its own config file |
private boolean | dropConnection |
private com.sun.enterprise.web.connector.grizzly.Handler | handler |
private int | maxHttpHeaderSize |
private int | timeouts |
private boolean | keepAliveKeep-alive flag. |
private boolean | errorHas erros occured? |
private MinaIoSession | ioSessionThe Mina IoSession used to bridge AsyncWeb with Grizzly. |
private org.apache.mina.common.ByteBuffer | minaByteBufferMina ByteBuffer implementation. |
private boolean | forcedReadRead as much bytes as we can before invoking AsyncWeb to avoid
attaching to the SelectionKey.attach(). |
private org.safehaus.asyncweb.transport.nio.HttpIOHandler | httpIOHandlerThe AsyncWeb entry point to handle request. |
Methods Summary |
---|
public void | doTask()Used when Grizzly ARP is enabled.
XXX Not Yet supported.
try {
process(taskContext.getInputStream(),
taskContext.getOutputStream());
} catch(Throwable ex){
SelectorThread.logger().log(Level.FINE,
"processorTask.errorProcessingRequest", ex);
} finally {
terminateProcess();
}
|
public int | getBufferSize()
return requestBufferSize;
|
public boolean | getDropConnection()
return dropConnection;
|
public com.sun.enterprise.web.connector.grizzly.Handler | getHandler()
return handler;
|
public int | getMaxPostSize()
throw new UnsupportedOperationException();
|
public java.lang.String | getRequestURI()
throw new UnsupportedOperationException();
|
public long | getWorkerThreadID()
throw new UnsupportedOperationException();
|
public void | initialize()Initialize the Mina session.
ioSession = new MinaIoSession();
|
public void | invokeAdapter()
throw new UnsupportedOperationException();
|
public boolean | isError()
return error;
|
public boolean | isKeepAlive()
return keepAlive;
|
public void | parseRequest()
throw new UnsupportedOperationException();
|
public boolean | parseRequest(java.io.InputStream input, java.io.OutputStream output, boolean keptAlive)
throw new UnsupportedOperationException();
|
public boolean | parseRequest(java.nio.channels.spi.AbstractSelectableChannel abstractSelectableChannel, boolean b)
return false;
|
public void | postProcess()
throw new UnsupportedOperationException();
|
public void | postProcess(java.io.InputStream input, java.io.OutputStream output)
throw new UnsupportedOperationException();
|
public void | postProcess(java.nio.channels.spi.AbstractSelectableChannel abstractSelectableChannel)
|
public void | postResponse()
throw new UnsupportedOperationException();
|
public void | preProcess()
throw new UnsupportedOperationException();
|
public void | preProcess(java.io.InputStream input, java.io.OutputStream output)
throw new UnsupportedOperationException();
|
public void | preProcess(java.nio.channels.spi.AbstractSelectableChannel abstractSelectableChannel)
|
public boolean | process(java.nio.channels.spi.AbstractSelectableChannel abstractSelectableChannel)
return false;
|
public boolean | process(java.io.InputStream input, java.io.OutputStream output)Delegate the request to AsyncWeb by simulating
ByteBufferInputStream bbInputStream =
(ByteBufferInputStream)input;
java.nio.ByteBuffer byteBuffer = bbInputStream.getByteBuffer();
if ( forcedRead ) {
readAllBytes(byteBuffer);
}
byteBuffer.flip();
httpIOHandler.sessionOpened(ioSession);
// We MUST avoid creating a wrapper on every request, but recycle the
// one used the previous transaction.
minaByteBuffer = ByteBuffer.wrap(byteBuffer);
httpIOHandler.dataRead(ioSession,minaByteBuffer);
return keepAlive;
|
private void | readAllBytes(java.nio.ByteBuffer byteBuffer)Use the temporary Selector to try to loads as much as we
can available bytes before delegating the request processing to
AsyncWeb
int count = 1;
int byteRead = 0;
Selector readSelector = null;
SelectionKey tmpKey = null;
try{
SocketChannel socketChannel = (SocketChannel)key.channel();
while (count > 0){
count = socketChannel.read(byteBuffer);
if ( count > 0 )
byteRead += count;
}
if ( byteRead == 0 ){
readSelector = SelectorFactory.getSelector();
if ( readSelector == null ){
return;
}
count = 1;
tmpKey = socketChannel
.register(readSelector,SelectionKey.OP_READ);
tmpKey.interestOps(tmpKey.interestOps() | SelectionKey.OP_READ);
int code = readSelector.selectNow();
tmpKey.interestOps(
tmpKey.interestOps() & (~SelectionKey.OP_READ));
if ( code == 0 ){
return;
}
while (count > 0){
count = socketChannel.read(byteBuffer);
if ( count > 0 )
byteRead += count;
}
}
} finally {
if (tmpKey != null)
tmpKey.cancel();
if ( readSelector != null){
// Bug 6403933
try{
readSelector.selectNow();
} catch (IOException ex){
;
}
SelectorFactory.returnSelector(readSelector);
}
}
|
public void | recycle()Always called when the connection is closed.
super.recycle();
keepAlive = true;
httpIOHandler.sessionClosed(ioSession);
ioSession.recycle();
|
public void | setBufferSize(int requestBufferSize)
this.requestBufferSize= requestBufferSize;
|
public void | setDropConnection(boolean dropConnection)
this.dropConnection = dropConnection;
|
public void | setHandler(com.sun.enterprise.web.connector.grizzly.Handler handler)
this.handler = handler;
|
public void | setIoHandler(org.safehaus.asyncweb.transport.nio.HttpIOHandler httpIOHandler)Set the HttpIoHandler .
this.httpIOHandler = httpIOHandler;
|
public void | setMaxHttpHeaderSize(int maxHttpHeaderSize)
this.maxHttpHeaderSize = maxHttpHeaderSize;
|
public void | setMaxPostSize(int mps)
throw new UnsupportedOperationException();
|
public void | setSocket(java.net.Socket socket)
|
public void | setTimeout(int timeouts)
this.timeouts = timeouts;
|
public void | taskEvent(com.sun.enterprise.web.connector.grizzly.TaskEvent event)Receive notifications from Task
if ( event.getStatus() == TaskEvent.START) {
taskContext = (TaskContext)event.attachement();
if ( taskEvent == null ) {
taskEvent = new TaskEvent<TaskContext>();
}
taskEvent.attach(taskContext);
}
|
public void | terminateProcess()Stop keep-aliving the connection.
keepAlive = false;
|