private ServerEnvironment createStandaloneServerEnvironment() {
    Properties props = new Properties();
    File home = new File("target/jbossas");
    delete(home);
    home.mkdir();
    delay(10);
    props.put(ServerEnvironment.HOME_DIR, home.getAbsolutePath());

    File standalone = new File(home, "standalone");
    standalone.mkdir();
    props.put(ServerEnvironment.SERVER_BASE_DIR, standalone.getAbsolutePath());

    File configuration = new File(standalone, "configuration");
    configuration.mkdir();
    props.put(ServerEnvironment.SERVER_CONFIG_DIR, configuration.getAbsolutePath());

    File xml = new File(configuration, "standalone.xml");
    try {
      xml.createNewFile();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    props.put(ServerEnvironment.JBOSS_SERVER_DEFAULT_CONFIG, "standalone.xml");

    return new ServerEnvironment(
        null,
        props,
        new HashMap<String, String>(),
        "standalone.xml",
        null,
        LaunchType.STANDALONE,
        runningModeControl.getRunningMode(),
        null);
  }
  private HostControllerEnvironment createHostControllerEnvironment() {
    try {
      Map<String, String> props = new HashMap<String, String>();
      File home = new File("target/jbossas");
      delete(home);
      home.mkdir();
      int sleep = 10;
      delay(sleep);
      props.put(HostControllerEnvironment.HOME_DIR, home.getAbsolutePath());

      File domain = new File(home, "domain");
      domain.mkdir();
      delay(sleep);
      props.put(HostControllerEnvironment.DOMAIN_BASE_DIR, domain.getAbsolutePath());

      File configuration = new File(domain, "configuration");
      configuration.mkdir();
      delay(sleep);
      props.put(HostControllerEnvironment.DOMAIN_CONFIG_DIR, configuration.getAbsolutePath());

      boolean isRestart = false;
      String modulePath = "";
      InetAddress processControllerAddress = InetAddress.getLocalHost();
      Integer processControllerPort = 9999;
      InetAddress hostControllerAddress = InetAddress.getLocalHost();
      Integer hostControllerPort = 1234;
      String defaultJVM = null;
      String domainConfig = null;
      String initialDomainConfig = null;
      String hostConfig = null;
      String initialHostConfig = null;
      RunningMode initialRunningMode = runningModeControl.getRunningMode();
      boolean backupDomainFiles = false;
      boolean useCachedDc = false;
      ProductConfig productConfig = new ProductConfig(null, "", props);
      return new HostControllerEnvironment(
          props,
          isRestart,
          modulePath,
          processControllerAddress,
          processControllerPort,
          hostControllerAddress,
          hostControllerPort,
          defaultJVM,
          domainConfig,
          initialDomainConfig,
          hostConfig,
          initialHostConfig,
          initialRunningMode,
          backupDomainFiles,
          useCachedDc,
          productConfig);
    } catch (UnknownHostException e) {
      // AutoGenerated
      throw new RuntimeException(e);
    }
  }
  @Override
  public void registerRemoteHost(ProxyController hostControllerClient)
      throws SlaveRegistrationException {
    if (!hostControllerInfo.isMasterDomainController()) {
      throw SlaveRegistrationException.forHostIsNotMaster();
    }

    if (runningModeControl.getRunningMode() == RunningMode.ADMIN_ONLY) {
      throw SlaveRegistrationException.forMasterInAdminOnlyMode(
          runningModeControl.getRunningMode());
    }
    PathAddress pa = hostControllerClient.getProxyNodeAddress();
    PathElement pe = pa.getElement(0);
    ProxyController existingController = modelNodeRegistration.getProxyController(pa);

    if (existingController != null || hostControllerInfo.getLocalHostName().equals(pe.getValue())) {
      throw SlaveRegistrationException.forHostAlreadyExists(pe.getValue());
    }
    modelNodeRegistration.registerProxyController(pe, hostControllerClient);
    hostProxies.put(pe.getValue(), hostControllerClient);

    Logger.getLogger("org.jboss.domain").info("Registered remote slave host " + pe.getValue());
  }
  // See superclass start. This method is invoked from a separate non-MSC thread after start. So we
  // can do a fair
  // bit of stuff
  @Override
  protected void boot(final BootContext context) throws ConfigurationPersistenceException {

    final ServiceTarget serviceTarget = context.getServiceTarget();
    try {
      super.boot(
          hostControllerConfigurationPersister
              .load()); // This parses the host.xml and invokes all ops

      final RunningMode currentRunningMode = runningModeControl.getRunningMode();

      // Now we know our management interface configuration. Install the server inventory
      Future<ServerInventory> inventoryFuture =
          ServerInventoryService.install(
              serviceTarget,
              this,
              environment,
              hostControllerInfo.getNativeManagementInterface(),
              hostControllerInfo.getNativeManagementPort());

      // Install the core remoting endpoint and listener
      ManagementRemotingServices.installRemotingEndpoint(
          serviceTarget,
          ManagementRemotingServices.MANAGEMENT_ENDPOINT,
          hostControllerInfo.getLocalHostName(),
          EndpointService.EndpointType.MANAGEMENT,
          null,
          null);

      if (!hostControllerInfo.isMasterDomainController() && !environment.isUseCachedDc()) {
        serverInventory = getFuture(inventoryFuture);

        if (hostControllerInfo.getRemoteDomainControllerHost() != null) {
          Future<MasterDomainControllerClient> clientFuture =
              RemoteDomainConnectionService.install(
                  serviceTarget,
                  getValue(),
                  hostControllerInfo.getLocalHostName(),
                  hostControllerInfo.getRemoteDomainControllerHost(),
                  hostControllerInfo.getRemoteDomainControllertPort(),
                  hostControllerInfo.getRemoteDomainControllerSecurityRealm(),
                  remoteFileRepository);
          MasterDomainControllerClient masterDomainControllerClient = getFuture(clientFuture);
          // Registers us with the master and gets down the master copy of the domain model to our
          // DC
          // TODO make sure that the RDCS checks env.isUseCachedDC, and if true falls through to
          // that
          try {
            masterDomainControllerClient.register();
          } catch (IllegalStateException e) {
            // We could not connect to the host
            log.error(HostControllerMessages.MESSAGES.cannotConnectToMaster(e));
            System.exit(ExitCodes.HOST_CONTROLLER_ABORT_EXIT_CODE);
          }
        } else if (currentRunningMode != RunningMode.ADMIN_ONLY) {
          // We could not connect to the host
          log.error(
              HostControllerMessages.MESSAGES.noDomainControllerConfigurationProvided(
                  currentRunningMode, CommandLineConstants.ADMIN_ONLY, RunningMode.ADMIN_ONLY));
          System.exit(ExitCodes.HOST_CONTROLLER_ABORT_EXIT_CODE);
        }

      } else {
        // TODO look at having LocalDomainControllerAdd do this, using Stage.IMMEDIATE for the steps
        // parse the domain.xml and load the steps
        ConfigurationPersister domainPersister =
            hostControllerConfigurationPersister.getDomainPersister();
        super.boot(domainPersister.load());

        ManagementRemotingServices.installManagementChannelServices(
            serviceTarget,
            ManagementRemotingServices.MANAGEMENT_ENDPOINT,
            new MasterDomainControllerOperationHandlerService(this, this),
            DomainModelControllerService.SERVICE_NAME,
            ManagementRemotingServices.DOMAIN_CHANNEL,
            null,
            null);
        serverInventory = getFuture(inventoryFuture);
      }

      // TODO look into adding some of these services in the handlers, but ON-DEMAND.
      // Then here just add some simple service that demands them

      ServerToHostOperationHandlerFactoryService.install(
          serviceTarget, ServerInventoryService.SERVICE_NAME, proxyExecutor);

      NativeManagementAddHandler.installNativeManagementServices(
          serviceTarget, hostControllerInfo, null, null);

      if (hostControllerInfo.getHttpManagementInterface() != null) {
        HttpManagementAddHandler.installHttpManagementServices(
            serviceTarget, hostControllerInfo, environment, null);
      }

      if (currentRunningMode == RunningMode.NORMAL) {
        startServers();
      }

      // TODO when to call hostControllerConfigurationPersister.successful boot? Look into this for
      // standalone as well; may be broken now
    } finally {
      try {
        finishBoot();
      } finally {
        bootstrapListener.tick();
      }
    }
  }