@Override
  protected void initModel(ManagementModel managementModel) {
    this.rootResource = managementModel.getRootResource();
    this.rootRegistration = managementModel.getRootResourceRegistration();

    GlobalNotifications.registerGlobalNotifications(rootRegistration, processType);
  }
Example #2
0
  public static void createRootRegistry(
      final ManagementResourceRegistration root,
      final HostControllerEnvironment environment,
      final IgnoredDomainResourceRegistry ignoredDomainResourceRegistry,
      final HostModelRegistrar hostModelRegistrar,
      final ProcessType processType,
      final DelegatingConfigurableAuthorizer authorizer,
      final Resource modelControllerResource) {
    // Add of the host itself
    final HostModelRegistrationHandler hostModelRegistratorHandler =
        new HostModelRegistrationHandler(
            environment,
            ignoredDomainResourceRegistry,
            hostModelRegistrar,
            modelControllerResource);
    root.registerOperationHandler(
        HostModelRegistrationHandler.DEFINITION, hostModelRegistratorHandler);

    // Global operations
    GlobalOperationHandlers.registerGlobalOperations(root, processType);
    // Global notifications
    GlobalNotifications.registerGlobalNotifications(root, processType);

    if (root.getOperationEntry(
            PathAddress.EMPTY_ADDRESS, ValidateOperationHandler.DEFINITION.getName())
        == null) { // this is hack
      root.registerOperationHandler(
          ValidateOperationHandler.DEFINITION, ValidateOperationHandler.INSTANCE);
    }
    root.registerOperationHandler(
        WhoAmIOperation.DEFINITION, WhoAmIOperation.createOperation(authorizer), true);

    // Other root resource operations
    root.registerOperationHandler(
        CompositeOperationHandler.DEFINITION, CompositeOperationHandler.INSTANCE);
  }
  protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    PathManagerService pathManagerService = new PathManagerService() {};
    GlobalOperationHandlers.registerGlobalOperations(registration, processType);
    registration.registerOperationHandler(
        CompositeOperationHandler.DEFINITION, CompositeOperationHandler.INSTANCE);

    GlobalNotifications.registerGlobalNotifications(registration, processType);

    registration.registerReadOnlyAttribute(
        LAUNCH_TYPE,
        new OperationStepHandler() {

          @Override
          public void execute(OperationContext context, ModelNode operation)
              throws OperationFailedException {
            context.getResult().set(TYPE_STANDALONE);
          }
        });

    TestServiceListener listener = new TestServiceListener();
    listener.reset(1);
    getContainer()
        .addService(PathManagerService.SERVICE_NAME, pathManagerService)
        .addListener(listener)
        .install();

    try {
      listener.latch.await(10, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException(e);
    }

    registration.registerSubModel(PathResourceDefinition.createSpecified(pathManagerService));
    registration.registerSubModel(
        CoreManagementResourceDefinition.forStandaloneServer(
            getAuthorizer(),
            getAuditLogger(),
            pathManagerService,
            new EnvironmentNameReader() {
              public boolean isServer() {
                return true;
              }

              public String getServerName() {
                return "Test";
              }

              public String getHostName() {
                return null;
              }

              public String getProductName() {
                return null;
              }
            },
            null,
            new ResourceDefinition[0]));

    Resource rootResource = managementModel.getRootResource();
    pathManagerService.addPathManagerResources(rootResource);

    ExtensionRegistry extensionRegistry =
        new ExtensionRegistry(
            ProcessType.STANDALONE_SERVER,
            new RunningModeControl(RunningMode.NORMAL),
            AuditLogger.NO_OP_LOGGER,
            getAuthorizer(),
            RuntimeHostControllerInfoAccessor.SERVER);
    extensionRegistry.setPathManager(pathManagerService);
    extensionRegistry.setWriterRegistry(new NullConfigurationPersister());
    JMXExtension extension = new JMXExtension();
    extension.initialize(
        extensionRegistry.getExtensionContext(
            "org.jboss.as.jmx", registration, ExtensionRegistryType.SLAVE));

    Resource coreManagementResource = Resource.Factory.create();
    rootResource.registerChild(
        CoreManagementResourceDefinition.PATH_ELEMENT, coreManagementResource);

    Resource accessAuthorizationResource = Resource.Factory.create();
    accessAuthorizationResource
        .getModel()
        .get(AccessAuthorizationResourceDefinition.PROVIDER.getName())
        .set(AccessAuthorizationResourceDefinition.Provider.SIMPLE.toString());
    coreManagementResource.registerChild(
        AccessAuthorizationResourceDefinition.PATH_ELEMENT, accessAuthorizationResource);
  }