dev@grizzly.java.net

[Patch] Issue 63 Removing explicit reference to WorkerThreadImpl

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 15 Feb 2008 12:35:26 -0500

Hi,

the expected contract when customizing the thread pool (Pipeline) should be:

1. Implement the Pipeline interface
2. The Thread created must implement the WorkerThread interface

Looks like the TLS method hasn't been moved to the WorkerThread
interface when we refactored from 1.0. Attached is a patch that remove
reference to WorkerThreadImpl in the code, so the contract can be
properly implemented.

Thanks

-- Jeanfrancois


Index: modules/comet/src/main/java/com/sun/grizzly/grizzlet/AsyncConnection.java
===================================================================
--- modules/comet/src/main/java/com/sun/grizzly/grizzlet/AsyncConnection.java (revision 813)
+++ modules/comet/src/main/java/com/sun/grizzly/grizzlet/AsyncConnection.java (working copy)
@@ -34,7 +34,7 @@
  *
  * @author Jeanfrancois Arcand
  */
-public interface AsyncConnection {
+public interface AsyncConnection<E,F> {
     
     /**
      * Return <tt>true</tt> is the current connection associated with
@@ -71,13 +71,13 @@
     /**
      * Return the GrizzletRequest associated with this AsynchConnection.
      */
- public GrizzletRequest getRequest();
+ public E getRequest();
     
     
     /**
      * Return the GrizzletResponse associated with this AsynchConnection.
      */
- public GrizzletResponse getResponse();
+ public F getResponse();
     
     
     /**
Index: modules/grizzly/src/main/java/com/sun/grizzly/filter/SSLEchoAsyncWriteQueueFilter.java
===================================================================
--- modules/grizzly/src/main/java/com/sun/grizzly/filter/SSLEchoAsyncWriteQueueFilter.java (revision 813)
+++ modules/grizzly/src/main/java/com/sun/grizzly/filter/SSLEchoAsyncWriteQueueFilter.java (working copy)
@@ -26,7 +26,7 @@
 import com.sun.grizzly.Context;
 import com.sun.grizzly.ProtocolFilter;
 import com.sun.grizzly.async.AsyncQueueDataProcessor;
-import com.sun.grizzly.util.WorkerThreadImpl;
+import com.sun.grizzly.util.WorkerThread;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import javax.net.ssl.SSLEngine;
@@ -41,7 +41,7 @@
     private static final String SSL_WRITE_PREPROCESSOR = "SSL_WRITE_PREPROCESSOR";
     
     public boolean execute(Context ctx) throws IOException {
- final WorkerThreadImpl workerThread = ((WorkerThreadImpl)Thread.currentThread());
+ final WorkerThread workerThread = ((WorkerThread)Thread.currentThread());
         ByteBuffer buffer = workerThread.getByteBuffer();
         buffer.flip();
         if (buffer.hasRemaining()) {
Index: modules/grizzly/src/main/java/com/sun/grizzly/util/WorkerThread.java
===================================================================
--- modules/grizzly/src/main/java/com/sun/grizzly/util/WorkerThread.java (revision 813)
+++ modules/grizzly/src/main/java/com/sun/grizzly/util/WorkerThread.java (working copy)
@@ -23,6 +23,7 @@
 package com.sun.grizzly.util;
 
 import java.nio.ByteBuffer;
+import javax.net.ssl.SSLEngine;
 
 /**
  * Simple interface to allow the addition of <code>Thread</code> attributes.
@@ -33,6 +34,48 @@
     
     
     /**
+ * Return the encrypted <code>ByteBuffer</code> used to handle request.
+ * @return <code>ByteBuffer</code>
+ */
+ public ByteBuffer getInputBB();
+
+
+ /**
+ * Set the encrypted <code>ByteBuffer</code> used to handle request.
+ * @param inputBB <code>ByteBuffer</code>
+ */
+ public void setInputBB(ByteBuffer inputBB);
+
+
+ /**
+ * Return the encrypted <code>ByteBuffer</code> used to handle response.
+ * @return <code>ByteBuffer</code>
+ */
+ public ByteBuffer getOutputBB();
+
+
+ /**
+ * Set the encrypted <code>ByteBuffer</code> used to handle response.
+ * @param outputBB <code>ByteBuffer</code>
+ */
+ public void setOutputBB(ByteBuffer outputBB);
+
+
+ /**
+ * Set the <code>SSLEngine</code>.
+ * @return <code>SSLEngine</code>
+ */
+ public SSLEngine getSSLEngine() ;
+
+
+ /**
+ * Get the <code>SSLEngine</code>.
+ * @param sslEngine <code>SSLEngine</code>
+ */
+ public void setSSLEngine(SSLEngine sslEngine) ;
+
+
+ /**
      * Set an instance of <code>ByteBuffer</code>
      * @param byteBuffer <code>ByteBuffer</code>
      */
Index: modules/grizzly/src/main/java/com/sun/grizzly/util/SSLOutputWriter.java
===================================================================
--- modules/grizzly/src/main/java/com/sun/grizzly/util/SSLOutputWriter.java (revision 813)
+++ modules/grizzly/src/main/java/com/sun/grizzly/util/SSLOutputWriter.java (working copy)
@@ -61,7 +61,7 @@
     public static long flushChannel(SelectableChannel channel, ByteBuffer bb)
             throws IOException{
       
- WorkerThreadImpl workerThread = (WorkerThreadImpl)Thread.currentThread();
+ WorkerThread workerThread = (WorkerThread)Thread.currentThread();
         SSLEngine sslEngine = workerThread.getSSLEngine();
         ByteBuffer outputBB = workerThread.getOutputBB();
         return flushChannel(channel,bb,outputBB,sslEngine);
Index: modules/grizzly/src/main/java/com/sun/grizzly/util/SSLUtils.java
===================================================================
--- modules/grizzly/src/main/java/com/sun/grizzly/util/SSLUtils.java (revision 813)
+++ modules/grizzly/src/main/java/com/sun/grizzly/util/SSLUtils.java (working copy)
@@ -41,9 +41,7 @@
 
 /**
  * SSL over NIO utility class. The class handle the SSLEngine operations
- * needed to support SSL over NIO. This class MUST be executed using
- * an WorkerThreadImpl as it rely on some WorkerThreadImpl buffers and
- * SSLEngine.
+ * needed to support SSL over NIO.
  *
  * TODO: Create an object that Wrap SSLEngine and its associated buffers.
  *
Index: modules/grizzly/src/main/java/com/sun/grizzly/util/ByteBufferInputStream.java
===================================================================
--- modules/grizzly/src/main/java/com/sun/grizzly/util/ByteBufferInputStream.java (revision 813)
+++ modules/grizzly/src/main/java/com/sun/grizzly/util/ByteBufferInputStream.java (working copy)
@@ -248,8 +248,8 @@
      * @throws java.io.IOException
      */
     protected int doSecureRead() throws IOException{
- final WorkerThreadImpl workerThread =
- (WorkerThreadImpl)Thread.currentThread();
+ final WorkerThread workerThread =
+ (WorkerThread)Thread.currentThread();
 
         if (byteBuffer.position() > 0) {
             byteBuffer.compact();