Index: test/java/com/sun/grizzly/TCPConnectorHandlerTest.java
===================================================================
--- test/java/com/sun/grizzly/TCPConnectorHandlerTest.java	(revision 329)
+++ test/java/com/sun/grizzly/TCPConnectorHandlerTest.java	(working copy)
@@ -22,7 +22,6 @@
  */
 package com.sun.grizzly;
 
-import com.sun.grizzly.connectioncache.client.CacheableConnectorHandlerPool;
 import com.sun.grizzly.filter.ReadFilter;
 import com.sun.grizzly.utils.ControllerUtils;
 import com.sun.grizzly.utils.EchoFilter;
Index: main/java/com/sun/grizzly/TCPConnectorHandler.java
===================================================================
--- main/java/com/sun/grizzly/TCPConnectorHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/TCPConnectorHandler.java	(working copy)
@@ -65,7 +65,7 @@
  *
  * @author Jeanfrancois Arcand
  */
-public class TCPConnectorHandler implements ConnectorHandler<TCPSelectorHandler>{
+public class TCPConnectorHandler implements ConnectorHandler<TCPSelectorHandler, CallbackHandler>{
     
     /**
      * The underlying TCPSelectorHandler used to mange SelectionKeys.
Index: main/java/com/sun/grizzly/IOEvent.java
===================================================================
--- main/java/com/sun/grizzly/IOEvent.java	(revision 329)
+++ main/java/com/sun/grizzly/IOEvent.java	(working copy)
@@ -48,4 +48,23 @@
      */
     public E attachment();
 
+    /**
+     * Simple IOEvent implementation
+     */
+    public class DefaultIOEvent<E> implements IOEvent<E> {
+        private E attachment;
+
+        public DefaultIOEvent(E attachment) {
+            this.attachment = attachment;
+        }
+
+        public E attach(E attachment) {
+            this.attachment = attachment;
+            return attachment;
+        }
+
+        public E attachment() {
+            return attachment;
+        }
+    }
 }
Index: main/java/com/sun/grizzly/ConnectorInstanceHandler.java
===================================================================
--- main/java/com/sun/grizzly/ConnectorInstanceHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/ConnectorInstanceHandler.java	(working copy)
@@ -23,6 +23,7 @@
 
 package com.sun.grizzly;
 
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 /**
@@ -85,4 +86,26 @@
         public abstract E newInstance();
     }
     
+    /**
+     * Concurrent Queue ConnectorInstanceHandler implementation
+     * @param E ConnectorHandler implementation this pool will manage
+     */
+    public class ConcurrentQueueDelegateCIH<E extends ConnectorHandler> 
+            extends ConcurrentQueueConnectorInstanceHandler<E> {
+        
+        // ConnectorHandler instance creator
+        private Callable<E> delegate;
+        
+        public ConcurrentQueueDelegateCIH(Callable<E> delegate) {
+            this.delegate = delegate;
+        }
+        
+        public E newInstance() {
+            try {
+                return delegate.call();
+            } catch(Exception e) {
+                throw new IllegalStateException("Unexpected exception");
+            }
+        }
+    }
 }
Index: main/java/com/sun/grizzly/UDPConnectorInstanceHandler.java
===================================================================
--- main/java/com/sun/grizzly/UDPConnectorInstanceHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/UDPConnectorInstanceHandler.java	(working copy)
@@ -1,38 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License).  You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the license at
- * https://glassfish.dev.java.net/public/CDDLv1.0.html or
- * glassfish/bootstrap/legal/CDDLv1.0.txt.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at glassfish/bootstrap/legal/CDDLv1.0.txt.
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * you own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
- */
-
-package com.sun.grizzly;
-
-/**
- * Default <code>ConnectorInstanceHandler</code> which use a 
- * <code>List</code> to pool <code>ConnectorHandler</code>
- *
- * @author Jeanfrancois
- */
-public class UDPConnectorInstanceHandler extends 
-        ConnectorInstanceHandler.ConcurrentQueueConnectorInstanceHandler<UDPConnectorHandler> {
-    
-    public UDPConnectorHandler newInstance() {
-        return new UDPConnectorHandler();
-    }
-}
Index: main/java/com/sun/grizzly/UDPSelectorHandler.java
===================================================================
--- main/java/com/sun/grizzly/UDPSelectorHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/UDPSelectorHandler.java	(working copy)
@@ -34,6 +34,7 @@
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.util.Iterator;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.logging.Level;
@@ -92,7 +93,9 @@
     public void preSelect(Context ctx) throws IOException {
         if (selector == null){
             try{
-                connectorInstanceHandler = new UDPConnectorInstanceHandler();
+                connectorInstanceHandler = new ConnectorInstanceHandler.
+                        ConcurrentQueueDelegateCIH(
+                        getConnectorInstanceHandlerDelegate());
                 datagramChannel = DatagramChannel.open();
                 datagramChannel.configureBlocking(false);
                 selector = Selector.open();                  
@@ -246,4 +249,14 @@
     public void setSocketTimeout(int socketTimeout) {
         throw new IllegalStateException(NOT_SUPPORTED);
     }    
+
+    //--------------- ConnectorInstanceHandler -----------------------------
+    @Override
+    protected Callable<ConnectorHandler> getConnectorInstanceHandlerDelegate() {
+        return new Callable<ConnectorHandler>() {
+            public ConnectorHandler call() throws Exception {
+                return new UDPConnectorHandler();
+            }
+        };
+    }
 }
Index: main/java/com/sun/grizzly/ConnectorHandler.java
===================================================================
--- main/java/com/sun/grizzly/ConnectorHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/ConnectorHandler.java	(working copy)
@@ -41,7 +41,7 @@
  * @param E a <code>SelectorHandler</code>
  * @author Jeanfrancois Arcand
  */
-public interface ConnectorHandler<E extends SelectorHandler> extends Handler, Closeable {
+public interface ConnectorHandler<E extends SelectorHandler, P extends CallbackHandler> extends Handler, Closeable {
     
     
      /**
@@ -63,7 +63,7 @@
      * @throws java.io.IOException 
      */
     public void connect(SocketAddress remoteAddress, 
-                        CallbackHandler callbackHandler,
+                        P callbackHandler,
                         E e) throws IOException;
 
     
@@ -77,7 +77,7 @@
      * @throws java.io.IOException
      */    
     public void connect(SocketAddress remoteAddress, 
-                        CallbackHandler callbackHandler) throws IOException;
+                        P callbackHandler) throws IOException;
     
     
     /**
@@ -104,7 +104,7 @@
      * @throws java.io.IOException
      */
     public void connect(SocketAddress remoteAddress, SocketAddress localAddress, 
-                        CallbackHandler callbackHandler,
+                        P callbackHandler,
                         E e) throws IOException;
 
     
@@ -119,7 +119,7 @@
      * @throws java.io.IOException 
      */    
     public void connect(SocketAddress remoteAddress, SocketAddress localAddress, 
-                        CallbackHandler callbackHandler) throws IOException;
+                        P callbackHandler) throws IOException;
     
     
     /**
@@ -205,7 +205,7 @@
      * 
      * @return callback handler
      */
-    public CallbackHandler getCallbackHandler();
+    public P getCallbackHandler();
     
     /**
      * Sets <code>ConnectorHandler</code>'s callback handler instance,
@@ -213,5 +213,5 @@
      * 
      * @param callbackHandler handler
      */
-    public void setCallbackHandler(CallbackHandler callbackHandler);
+    public void setCallbackHandler(P callbackHandler);
 }
Index: main/java/com/sun/grizzly/UDPConnectorHandler.java
===================================================================
--- main/java/com/sun/grizzly/UDPConnectorHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/UDPConnectorHandler.java	(working copy)
@@ -46,7 +46,7 @@
  * 
  * @author Jeanfrancois Arcand
  */
-public class UDPConnectorHandler implements ConnectorHandler<UDPSelectorHandler>{
+public class UDPConnectorHandler implements ConnectorHandler<UDPSelectorHandler, CallbackHandler>{
      
     /**
      * The underlying UDPSelectorHandler used to mange SelectionKeys.
Index: main/java/com/sun/grizzly/connectioncache/client/CacheableConnectorHandler.java
===================================================================
--- main/java/com/sun/grizzly/connectioncache/client/CacheableConnectorHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/connectioncache/client/CacheableConnectorHandler.java	(working copy)
@@ -39,7 +39,7 @@
  *
  * @author Alexey Stashok
  */
-public class CacheableConnectorHandler implements ConnectorHandler<SelectorHandler>,
+public class CacheableConnectorHandler implements ConnectorHandler<SelectorHandler, CallbackHandler>,
         ContactInfo<ConnectorHandler>, CallbackHandler {
     private SocketAddress targetAddress;
     private Protocol protocol;
@@ -231,15 +231,7 @@
         Selector protocolSelector = underlyingConnectorHandler.getSelectorHandler().getSelector();
         SelectionKey key = underlyingConnectorHandler.getUnderlyingChannel().keyFor(protocolSelector);
         final Context context = parentPool.getController().pollContext(key);
-        onConnect(new IOEvent<Context>() {
-            public Context attach(Context e) {
-                return context;
-            }
-            
-            public Context attachment() {
-                return context;
-            }
-        });
+        onConnect(new IOEvent.DefaultIOEvent<Context>(context));
     }
     
     //---------------------- CallbackHandler implementation --------------------------------
Index: main/java/com/sun/grizzly/filter/SSLReadFilter.java
===================================================================
--- main/java/com/sun/grizzly/filter/SSLReadFilter.java	(revision 329)
+++ main/java/com/sun/grizzly/filter/SSLReadFilter.java	(working copy)
@@ -114,7 +114,7 @@
     /**
      * Encrypted ByteBuffer default size.
      */
-    protected int inputBBSize = 5 * 4096;    
+    protected int inputBBSize = 5 * 4096;
     
     
     public SSLReadFilter() {
@@ -177,7 +177,7 @@
      *         needs to be invoked.
      */
     public boolean postExecute(Context ctx) throws IOException {
-        ctx.setProtocol(Controller.Protocol.TCP);
+        ctx.setProtocol(Controller.Protocol.TLS);
         if (ctx.getKeyRegistrationState()
                 == Context.KeyRegistrationState.CANCEL){
             ctx.getController().cancelKey(ctx.getSelectionKey());
@@ -266,8 +266,8 @@
         boolean OK = true;    
         try{ 
             byteBuffer = SSLUtils.doHandshake
-                         (key,byteBuffer,inputBB,outputBB,sslEngine,
-                          handshakeStatus,timeout);
+                         ((SocketChannel) key.channel(), byteBuffer, inputBB,
+                    outputBB, sslEngine, handshakeStatus, timeout);
             if (doRead(key) == -1){
                 throw new EOFException();
             }
@@ -313,7 +313,7 @@
                 } catch (SSLException ex){
                     ;
                 }
-            } 
+            }
         }
     }
     
Index: main/java/com/sun/grizzly/TCPConnectorInstanceHandler.java
===================================================================
--- main/java/com/sun/grizzly/TCPConnectorInstanceHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/TCPConnectorInstanceHandler.java	(working copy)
@@ -1,38 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License).  You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the license at
- * https://glassfish.dev.java.net/public/CDDLv1.0.html or
- * glassfish/bootstrap/legal/CDDLv1.0.txt.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at glassfish/bootstrap/legal/CDDLv1.0.txt.
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * you own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
- */
-
-package com.sun.grizzly;
-
-/**
- * Default <code>ConnectorInstanceHandler</code> which use a 
- * <code>List</code> to pool <code>ConnectorHandler</code>
- *
- * @author Jeanfrancois
- */
-public class TCPConnectorInstanceHandler extends
-        ConnectorInstanceHandler.ConcurrentQueueConnectorInstanceHandler<TCPConnectorHandler> {
-    
-    public TCPConnectorHandler newInstance() {
-        return new TCPConnectorHandler();
-    }
-}
Index: main/java/com/sun/grizzly/TCPSelectorHandler.java
===================================================================
--- main/java/com/sun/grizzly/TCPSelectorHandler.java	(revision 329)
+++ main/java/com/sun/grizzly/TCPSelectorHandler.java	(working copy)
@@ -39,6 +39,7 @@
 import java.nio.channels.SocketChannel;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.logging.Level;
@@ -232,7 +233,9 @@
     public void preSelect(Context ctx) throws IOException {
         if (selector == null){
             try{
-                connectorInstanceHandler = new TCPConnectorInstanceHandler();
+                connectorInstanceHandler = new ConnectorInstanceHandler.
+                        ConcurrentQueueDelegateCIH(
+                        getConnectorInstanceHandlerDelegate());
                 
                 // Create the socket listener
                 selector = Selector.open();
@@ -550,8 +553,7 @@
     protected void invokeCallbackHandler(Context context) throws IOException{
         context.setProtocol(protocol());
         
-        IOEvent<Context>ioEvent = createIOEvent();
-        ioEvent.attach(context);
+        IOEvent<Context>ioEvent = new IOEvent.DefaultIOEvent<Context>(context);
         context.setIOEvent(ioEvent);
         try {
             context.execute();
@@ -736,27 +738,8 @@
     public void setReuseAddress(boolean reuseAddress) {
         this.reuseAddress = reuseAddress;
     }
-    
+        
     /**
-     * Create IOEvent instance
-     * @return IOEvent
-     */
-    protected static <E> IOEvent<E> createIOEvent() {
-        return new IOEvent<E>() {
-            private E context;
-            public E attach(E context){
-                this.context = context;
-                return context;
-            }
-            
-            public E attachment(){
-                return context;
-            }
-        };        
-    }
-    
-    
-    /**
      * Return the Pipeline used to execute this SelectorHandler's
      * SelectionKey ops
      * @return The pipeline to use, or null if the Controller's Pipeline
@@ -781,4 +764,18 @@
     public void setSelectionKeyHandler(SelectionKeyHandler selectionKeyHandler) {
         this.selectionKeyHandler = selectionKeyHandler;
     }
+    
+    //--------------- ConnectorInstanceHandler -----------------------------
+    /**
+     * Return <Callable>factory<Callable> object, which knows how
+     * to create <code>ConnectorInstanceHandler<code> corresponding to the protocol
+     * @return <Callable>factory</code>
+     */
+    protected Callable<ConnectorHandler> getConnectorInstanceHandlerDelegate() {
+        return new Callable<ConnectorHandler>() {
+            public ConnectorHandler call() throws Exception {
+                return new TCPConnectorHandler();
+            }
+        };
+    }
 }
Index: main/java/com/sun/grizzly/util/SSLUtils.java
===================================================================
--- main/java/com/sun/grizzly/util/SSLUtils.java	(revision 329)
+++ main/java/com/sun/grizzly/util/SSLUtils.java	(working copy)
@@ -69,24 +69,23 @@
     
     /**
      * Read encrypted bytes using an <code>SSLEngine</code>.
-     * @param key The SelectionKey
+     * @param socketChannel The SocketChannel
      * @param inputBB The byteBuffer to store encrypted bytes
      * @param sslEngine The SSLEngine uses to manage the SSL operations.
      * @param timeout The Selector.select() timeout value. A value of 0 will
      *                be exectuted as a Selector.selectNow();
      * @return the bytes read.
      */
-    public static int doRead(SelectionKey key, ByteBuffer inputBB, 
+    public static int doRead(SocketChannel socketChannel, ByteBuffer inputBB, 
             SSLEngine sslEngine, int timeout){ 
         
-        if (key == null) return -1;
+        if (socketChannel == null) return -1;
 
         int count = 1;
         int byteRead = 0;
         Selector readSelector = null;
         SelectionKey tmpKey = null;
         try{
-            SocketChannel socketChannel = (SocketChannel)key.channel();
             while (count > 0){
                 count = socketChannel.read(inputBB);
                 
@@ -290,7 +289,7 @@
     
     /**
      * Perform an SSL handshake using the SSLEngine. 
-     * @param key the <code>SelectionKey</code>
+     * @param socketChannel the <code>SocketChannel</code>
      * @param byteBuffer The application <code>ByteBuffer</code>
      * @param inputBB The encrypted input <code>ByteBuffer</code>
      * @param outputBB The encrypted output <code>ByteBuffer</code>
@@ -300,18 +299,18 @@
      * @throws java.io.IOException 
      * @throw IOException if the handshake fail.
      */
-    public static ByteBuffer doHandshake(SelectionKey key,
+    public static ByteBuffer doHandshake(SocketChannel socketChannel,
             ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer outputBB,
             SSLEngine sslEngine, HandshakeStatus handshakeStatus) 
             throws IOException {
-        return doHandshake(key,byteBuffer,inputBB,outputBB,sslEngine,
-                           handshakeStatus,readTimeout);
+        return doHandshake(socketChannel, byteBuffer, inputBB, outputBB,
+                sslEngine, handshakeStatus, readTimeout);
     }
 
     
     /**
      * Perform an SSL handshake using the SSLEngine. 
-     * @param key the <code>SelectionKey</code>
+     * @param socketChannel the <code>SocketChannel</code>
      * @param byteBuffer The application <code>ByteBuffer</code>
      * @param inputBB The encrypted input <code>ByteBuffer</code>
      * @param outputBB The encrypted output <code>ByteBuffer</code>
@@ -320,9 +319,9 @@
      * @param timeout 
      * @return byteBuffer the new ByteBuffer
      * @throws java.io.IOException 
-     * @throw IOException if the handshake fail.
+     * @throws IOException if the handshake fail.
      */
-    public static ByteBuffer doHandshake(SelectionKey key,
+    public static ByteBuffer doHandshake(SocketChannel socketChannel,
             ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer outputBB,
             SSLEngine sslEngine, HandshakeStatus handshakeStatus,int timeout) 
             throws IOException {
@@ -332,7 +331,7 @@
         while (handshakeStatus != HandshakeStatus.FINISHED){
             switch (handshakeStatus) {
                case NEED_UNWRAP:
-                    if (doRead(key,inputBB,sslEngine, timeout) <= eof) {
+                    if (doRead(socketChannel,inputBB,sslEngine, timeout) <= eof) {
                         try{
                             sslEngine.closeInbound();
                         } catch (IOException ex){
@@ -390,9 +389,9 @@
                             }
 
                             // Flush all Server bytes to the client.
-                            if (key != null) {
+                            if (socketChannel != null) {
                                 OutputWriter.flushChannel(
-                                        (SocketChannel)key.channel(), outputBB);
+                                        socketChannel, outputBB);
                                 outputBB.clear();
                             }
                             break;
Index: main/java/com/sun/grizzly/util/ByteBufferInputStream.java
===================================================================
--- main/java/com/sun/grizzly/util/ByteBufferInputStream.java	(revision 329)
+++ main/java/com/sun/grizzly/util/ByteBufferInputStream.java	(working copy)
@@ -284,7 +284,7 @@
         // bytes, the byteBuffer will be empty event if some encrypted bytes
         // are available. 
         while (byteBuffer.position() == initialPosition){
-            byteRead += SSLUtils.doRead(key,workerThread.getInputBB(),
+            byteRead += SSLUtils.doRead((SocketChannel) key.channel(), workerThread.getInputBB(),
                     workerThread.getSSLEngine(),readTimeout);
 
             if (byteRead > 0 || workerThread.getInputBB().position() > 0) {
@@ -371,10 +371,9 @@
                 }
                 SelectorFactory.returnSelector(readSelector);
             }
-
+            
             byteBuffer.flip();
         }
-        
         return byteRead;
     }