/** {@inheritDoc} */
  @Override
  public synchronized void start(final StartContext context) throws StartException {
    log.info("Starting Domain Controller");
    final DomainController controller = new DomainControllerImpl(configurationPersister);
    final List<ModelNode> updates;
    try {
      updates = configurationPersister.load();
    } catch (final Exception e) {
      log.error("failed to start domain controller", e);
      throw new StartException(e);
    }

    final AtomicInteger count = new AtomicInteger(1);
    final ResultHandler resultHandler =
        new ResultHandler() {
          @Override
          public void handleResultFragment(final String[] location, final ModelNode result) {}

          @Override
          public void handleResultComplete(final ModelNode compensatingOperation) {
            if (count.decrementAndGet() == 0) {
              // some action
            }
          }

          @Override
          public void handleFailed(final ModelNode failureDescription) {
            if (count.decrementAndGet() == 0) {
              // some action
            }
          }

          @Override
          public void handleCancellation() {
            if (count.decrementAndGet() == 0) {
              // some action
            }
          }
        };
    for (ModelNode update : updates) {
      count.incrementAndGet();
      controller.execute(update, resultHandler);
    }
    if (count.decrementAndGet() == 0) {
      // some action?
    }
    this.controller = controller;
  }
Пример #2
0
 public static void initializeMasterDomainRegistry(
     final ManagementResourceRegistration root,
     final ExtensibleConfigurationPersister configurationPersister,
     final ContentRepository contentRepository,
     final HostFileRepository fileRepository,
     final DomainController domainController,
     final UnregisteredHostChannelRegistry channelRegistry,
     final ExtensionRegistry extensionRegistry) {
   initializeDomainRegistry(
       root,
       configurationPersister,
       contentRepository,
       fileRepository,
       true,
       domainController,
       channelRegistry,
       domainController.getLocalHostInfo(),
       extensionRegistry);
 }