Methods Summary |
---|
public void | allocateBuffers()Allocate themandatory ByteBuffer s. Since the ByteBuffer
are maintaned on the SSLWorkerThread lazily, this method
makes sure the ByteBuffers are properly allocated and configured.
int expectedSize = sslEngine.getSession().getPacketBufferSize();
if (inputBBSize < expectedSize){
inputBBSize = expectedSize;
}
if (inputBB != null && inputBB.capacity() < inputBBSize) {
ByteBuffer newBB = ByteBuffer.allocate(inputBBSize);
inputBB.flip();
newBB.put(inputBB);
inputBB = newBB;
} else if (inputBB == null){
inputBB = ByteBuffer.allocate(inputBBSize);
}
outputBB = ByteBuffer.allocate(inputBBSize);
if (byteBuffer == null){
byteBuffer = ByteBuffer.allocate(inputBBSize * 2);
}
expectedSize = sslEngine.getSession().getApplicationBufferSize();
if (expectedSize > byteBuffer.capacity()) {
ByteBuffer newBB = ByteBuffer.allocate(expectedSize);
byteBuffer.flip();
newBB.put(byteBuffer);
byteBuffer = newBB;
}
outputBB.position(0);
outputBB.limit(0);
|
public void | configureProcessorTask()Set appropriate attribute on the ProcessorTask .
super.configureProcessorTask();
if ( !getTaskListeners().contains(processorTask) ){
processorTask.addTaskListener(this);
addTaskListener((TaskListener)processorTask);
}
processorTask.initialize();
SSLAsyncOutputBuffer outputBuffer =
((SSLAsyncProcessorTask)processorTask).getSSLAsyncOutputBuffer();
outputBuffer.setSSLEngine(sslEngine);
outputBuffer.setOutputBB(outputBB);
|
public boolean | executeProcessorTask()Execute the ProcessorTask
if (SelectorThread.logger().isLoggable(Level.FINEST))
SelectorThread.logger().log(Level.FINEST,"executeProcessorTask");
if (algorithm.getHandler() != null && algorithm.getHandler()
.handle(null,Handler.REQUEST_BUFFERED) == Handler.BREAK){
return true;
}
if (taskEvent == null){
taskContext = new TaskContext();
taskEvent = new TaskEvent<TaskContext>(taskContext);
}
// Call the listener and execute the task on it's own pipeline.
taskEvent.setStatus(TaskEvent.START);
taskContext.setInputStream(inputStream);
taskEvent.attach(taskContext);
fireTaskEvent(taskEvent);
return false;
|
public void | initialize(com.sun.enterprise.web.connector.grizzly.StreamAlgorithm algorithm, boolean useDirectByteBuffer, boolean useByteBufferView)Initialize this object.
type = READ_TASK;
this.algorithm = algorithm;
inputStream = new SSLAsyncStream();
this.useDirectByteBuffer = useDirectByteBuffer;
this.useByteBufferView = useByteBufferView;
|
protected void | manageKeepAlive(boolean keepAlive, int count, java.lang.Exception exception)Manage the SelectionKey
// The key is invalid when the Task has been cancelled.
if (count == -1 || exception != null){
if ( exception != null){
// Make sure we have detached the processorTask
detachProcessor();
if (SelectorThread.logger().isLoggable(Level.FINE)){
SelectorThread.logger().log
(Level.FINE,
"SocketChannel Read Exception:",exception);
}
}
terminate(false);
}
|
protected boolean | process()
boolean keepAlive = false;
SocketChannel socketChannel = (SocketChannel)key.channel();
Socket socket = socketChannel.socket();
algorithm.setSocketChannel(socketChannel);
inputStream.setSelectionKey(key);
((SSLAsyncStream)inputStream).setSslEngine(sslEngine);
((SSLAsyncStream)inputStream).setInputBB(inputBB);
// Get a processor task. If the processorTask != null, that means we
// failed to load all the bytes in a single channel.read().
if (processorTask == null){
attachProcessor(selectorThread.getProcessorTask());
}
// Always true with the NoParsingAlgorithm
if (algorithm.parse(byteBuffer)){
return executeProcessorTask();
} else {
// Never happens with the default StreamAlgorithm
return true;
}
|
public void | recycle()Clear the current state and make this object ready for another request.
byteBuffer = algorithm.postParse(byteBuffer);
byteBuffer.clear();
inputStream.recycle();
algorithm.recycle();
key = null;
inputStream.setSelectionKey(null);
handshake = true;
inputBB.clear();
outputBB.clear();
outputBB.position(0);
outputBB.limit(0);
sslEngine = null;
detachProcessor();
|
public void | terminate(boolean keepAlive)Complete the transaction.
if (processorTask != null && processorTask.isKeepAlive()){
detachProcessor();
registerKey();
returnTask();
} else {
super.terminate(keepAlive);
}
|