RemoteDomainConnection(
     final String localHostName,
     final ModelNode localHostInfo,
     final ProtocolChannelClient.Configuration configuration,
     final SecurityRealm realm,
     final String username,
     final List<DiscoveryOption> discoveryOptions,
     final ExecutorService executorService,
     final ScheduledExecutorService scheduledExecutorService,
     final HostRegistrationCallback callback) {
   this.callback = callback;
   this.localHostName = localHostName;
   this.localHostInfo = localHostInfo;
   this.configuration = configuration;
   this.username = username;
   this.realm = realm;
   this.discoveryOptions = discoveryOptions;
   this.executorService = executorService;
   this.channelHandler = new ManagementChannelHandler(this, executorService);
   this.scheduledExecutorService = scheduledExecutorService;
   this.connectionManager = ProtocolConnectionManager.create(new InitialConnectTask());
 }
 @Override
 public void close() throws IOException {
   synchronized (this) {
     try {
       if (isConnected()) {
         try {
           channelHandler
               .executeRequest(new UnregisterModelControllerRequest(), null)
               .getResult()
               .await();
         } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
         }
       }
     } finally {
       try {
         connectionManager.shutdown();
       } finally {
         super.close();
       }
     }
   }
 }
 /**
  * Try to connect to the remote host.
  *
  * @throws IOException
  */
 protected void connect() throws IOException {
   // Connect to the remote HC
   connectionManager.connect();
 }