public static ServiceController<?> addService(
      ServiceTarget serviceTarget,
      HostPathManagerService service,
      HostControllerEnvironment hostEnvironment) {
    ServiceBuilder<?> serviceBuilder = serviceTarget.addService(SERVICE_NAME, service);

    service.addHardcodedAbsolutePath(
        serviceTarget,
        HostControllerEnvironment.HOME_DIR,
        hostEnvironment.getHomeDir().getAbsolutePath());
    service.addHardcodedAbsolutePath(
        serviceTarget,
        HostControllerEnvironment.DOMAIN_CONFIG_DIR,
        hostEnvironment.getDomainConfigurationDir().getAbsolutePath());
    service.addHardcodedAbsolutePath(
        serviceTarget,
        HostControllerEnvironment.DOMAIN_DATA_DIR,
        hostEnvironment.getDomainDataDir().getAbsolutePath());
    service.addHardcodedAbsolutePath(
        serviceTarget,
        HostControllerEnvironment.DOMAIN_LOG_DIR,
        hostEnvironment.getDomainLogDir().getAbsolutePath());
    service.addHardcodedAbsolutePath(
        serviceTarget,
        HostControllerEnvironment.DOMAIN_TEMP_DIR,
        hostEnvironment.getDomainTempDir().getAbsolutePath());
    service.addHardcodedAbsolutePath(
        serviceTarget,
        HostControllerEnvironment.CONTROLLER_TEMP_DIR,
        hostEnvironment.getDomainTempDir().getAbsolutePath());

    return serviceBuilder.install();
  }
  @Override
  public void start(StartContext context) throws StartException {

    processState.setStarting();

    final ProductConfig config = environment.getProductConfig();
    final String prettyVersion = config.getPrettyVersionString();
    ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion);
    if (ServerLogger.CONFIG_LOGGER.isDebugEnabled()) {
      final Properties properties = System.getProperties();
      final StringBuilder b = new StringBuilder(8192);
      b.append("Configured system properties:");
      for (String property : new TreeSet<String>(properties.stringPropertyNames())) {
        b.append("\n\t")
            .append(property)
            .append(" = ")
            .append(properties.getProperty(property, "<undefined>"));
      }
      ServerLogger.CONFIG_LOGGER.debug(b);
      ServerLogger.CONFIG_LOGGER.debugf("VM Arguments: %s", getVMArguments());
      if (ServerLogger.CONFIG_LOGGER.isTraceEnabled()) {
        b.setLength(0);
        final Map<String, String> env = System.getenv();
        b.append("Configured system environment:");
        for (String key : new TreeSet<String>(env.keySet())) {
          b.append("\n\t").append(key).append(" = ").append(env.get(key));
        }
        ServerLogger.CONFIG_LOGGER.trace(b);
      }
    }
    final ServiceTarget serviceTarget = context.getChildTarget();
    final ServiceController<?> myController = context.getController();
    final ServiceContainer serviceContainer = myController.getServiceContainer();
    futureContainer = new FutureServiceContainer();

    long startTime = this.startTime;
    if (startTime == -1) {
      startTime = System.currentTimeMillis();
    } else {
      this.startTime = -1;
    }

    final BootstrapListener bootstrapListener =
        new BootstrapListener(
            serviceContainer,
            startTime,
            serviceTarget,
            futureContainer,
            prettyVersion + " (Host Controller)");
    bootstrapListener.getStabilityMonitor().addController(myController);

    // The first default services are registered before the bootstrap operations are executed.

    // Install the process controller client
    final ProcessControllerConnectionService processControllerClient =
        new ProcessControllerConnectionService(environment, authCode);
    serviceTarget
        .addService(ProcessControllerConnectionService.SERVICE_NAME, processControllerClient)
        .install();

    // Executor Services
    final HostControllerExecutorService executorService = new HostControllerExecutorService();
    serviceTarget
        .addService(HC_EXECUTOR_SERVICE_NAME, executorService)
        .addAliases(
            ManagementRemotingServices
                .SHUTDOWN_EXECUTOR_NAME) // Use this executor for mgmt shutdown for now
        .install();

    // Install required path services. (Only install those identified as required)
    HostPathManagerService hostPathManagerService = new HostPathManagerService();
    HostPathManagerService.addService(serviceTarget, hostPathManagerService, environment);

    HttpListenerRegistryService.install(serviceTarget);

    // Add product config service
    final Value<ProductConfig> productConfigValue = new ImmediateValue<ProductConfig>(config);
    serviceTarget
        .addService(
            Services.JBOSS_PRODUCT_CONFIG_SERVICE,
            new ValueService<ProductConfig>(productConfigValue))
        .setInitialMode(ServiceController.Mode.ACTIVE)
        .install();

    DomainModelControllerService.addService(
        serviceTarget,
        environment,
        runningModeControl,
        processState,
        bootstrapListener,
        hostPathManagerService);
  }