|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
   package diy.middleware.sockets;  | 
  |  17 |     | 
     | 
  |  18 |     | 
   import java.io.IOException;  | 
  |  19 |     | 
   import java.net.Socket;  | 
  |  20 |     | 
   import java.net.UnknownHostException;  | 
  |  21 |     | 
   import java.util.concurrent.BlockingQueue;  | 
  |  22 |     | 
     | 
  |  23 |     | 
   import diy.middleware.Connector;  | 
  |  24 |     | 
     | 
  |  25 |    3 |    public class SocketConnector implements Connector { | 
  |  26 |     | 
             | 
  |  27 |     | 
           private BlockingQueue<SocketConnection> socketQueue;  | 
  |  28 |     | 
     | 
  |  29 |     | 
           public void setSocketQueue(BlockingQueue<SocketConnection> socketQueue) { | 
  |  30 |    3 |                    this.socketQueue = socketQueue;  | 
  |  31 |    3 |            }  | 
  |  32 |     | 
             | 
  |  33 |     | 
           public void connect(String host, int port, String sessionId) throws UnknownHostException, IOException, InterruptedException { | 
  |  34 |    5 |                    final Socket socket = new Socket(host, port);  | 
  |  35 |    5 |                    socketQueue.put(new SocketConnection(sessionId, socket));  | 
  |  36 |    5 |            }  | 
  |  37 |     | 
             | 
  |  38 |     | 
   }  |