class ConsoleConnectionFactory {

  public ConsoleConnection connect(String host, int port)
    throws ConsoleConnectionException {

    try {
      final ClientSender sender = ClientSender.connect(
        new Connector(host, port, ConnectionType.CONSOLE_CLIENT), null);

      final Runnable keepAlive = new Runnable() {
        @Override
        public void run() {
          try {
            sender.sendKeepAlive();
          }
          catch (CommunicationException e) {
            // Connection is dead, terminate task.
            throw new RuntimeException(e);
          }
        }
      };

      m_executor.scheduleWithFixedDelay(keepAlive,
                                        0,
                                        1,
                                        TimeUnit.SECONDS);

      return new ConsoleConnectionImplementation(sender);
    }
    catch (CommunicationException e) {
      throw new ConsoleConnectionException("Failed to connect", e);
    }
  }

  public  ConsoleConnectionFactory();
  protected  ConsoleConnectionFactory(ScheduledExecutorService executor);

}