package aio;
/*
 * Copyright 2014 Yang Fan.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import aio.context.ClientContext;
import serialization.KryoSerializer;
import serialization.Serializer;

import java.nio.channels.AsynchronousSocketChannel;

public class ConnectableClientFactory {

    private ClientContext connectableClientContext;

    public ConnectableClientFactory(ClientContext connectableClientContext) {
        this.connectableClientContext = connectableClientContext;
    }

    public AioClient newConnectableClient(AsynchronousSocketChannel clientChannel, Serializer serializer) {
        return new AioClient(clientChannel, serializer, KryoSerializer.getInstance().copy(connectableClientContext), true);
    }
}

@@ -707,16 +707,95 @@
 lizer;%0A%0A
+import java.io.IOException;%0Aimport java.nio.channels.AsynchronousChannelGroup;%0A
 import j
@@ -837,16 +837,55 @@
 Channel;
+%0Aimport java.util.concurrent.Executors;
 %0A%0Apublic
@@ -931,16 +931,22 @@
 private 
+final 
 ClientCo
@@ -978,16 +978,126 @@
 ntext;%0A%0A
+    private final AsynchronousChannelGroup connectableClientGroup;%0A%0A    private final Serializer serializer;%0A%0A
     publ
@@ -1162,17 +1162,59 @@
 tContext
-)
+, Serializer serializer) throws IOException
  %7B%0A     
@@ -1274,16 +1274,216 @@
 ontext;%0A
+        this.serializer = serializer;%0A        this.connectableClientGroup = AsynchronousChannelGroup.withFixedThreadPool(Runtime.getRuntime().availableProcessors(), Executors.defaultThreadFactory());%0A
     %7D%0A%0A 
@@ -1523,16 +1523,47 @@
 eClient(
+) throws IOException %7B%0A        
 Asynchro
@@ -1597,34 +1597,66 @@
 nnel
-, Serializer serializer) %7B
+ = AsynchronousSocketChannel.open(connectableClientGroup);
 %0A   

Refactor factory api