예제 #1
0
  @Override
  protected void initModel(ManagementModel managementModel) {
    this.rootResource = managementModel.getRootResource();
    this.rootRegistration = managementModel.getRootResourceRegistration();

    GlobalNotifications.registerGlobalNotifications(rootRegistration, processType);
  }
  @Override
  protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(registration, ProcessType.STANDALONE_SERVER);
    NotificationDefinition notificationDefinition =
        NotificationDefinition.Builder.create(
                MY_TYPE,
                new NonResolvingResourceDescriptionResolver() {
                  @Override
                  public String getNotificationDescription(
                      String notificationType, Locale locale, ResourceBundle bundle) {
                    return NOTIFICATION_DESCRIPTION;
                  }
                })
            .setDataValueDescriptor(
                new NotificationDefinition.DataValueDescriptor() {
                  @Override
                  public ModelNode describe(ResourceBundle bundle) {
                    return DATA_TYPE_DESCRIPTION;
                  }
                })
            .build();

    registration.registerNotification(notificationDefinition);
  }
예제 #3
0
  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);
  }