org.jboss.as.controller.registry.ManagementResourceRegistration Java Examples

The following examples show how to use org.jboss.as.controller.registry.ManagementResourceRegistration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeycloakExtension.java    From keycloak with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initialize(final ExtensionContext context) {
    KeycloakLogger.ROOT_LOGGER.debug("Activating Keycloak Extension");
    final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MGMT_API_VERSION);

    ManagementResourceRegistration registration = subsystem.registerSubsystemModel(KEYCLOAK_SUBSYSTEM_RESOURCE);
    registration.registerSubModel(REALM_DEFINITION);
    ManagementResourceRegistration secureDeploymentRegistration = registration.registerSubModel(SECURE_DEPLOYMENT_DEFINITION);
    secureDeploymentRegistration.registerSubModel(CREDENTIAL_DEFINITION);
    secureDeploymentRegistration.registerSubModel(REDIRECT_RULE_DEFINITON);

    ManagementResourceRegistration secureServerRegistration = registration.registerSubModel(SECURE_SERVER_DEFINITION);
    secureServerRegistration.registerSubModel(CREDENTIAL_DEFINITION);
    secureServerRegistration.registerSubModel(REDIRECT_RULE_DEFINITON);

    subsystem.registerXMLElementWriter(PARSER);
}
 
Example #2
Source File: ApplicationTypeConstraintUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setupResources(boolean isA, boolean isB) {

        a.setConfiguredApplication(isA);
        b.setConfiguredApplication(isB);

        ResourceDefinition rootRd = new SimpleResourceDefinition(null, new NonResolvingResourceDescriptionResolver()) {
            @Override
            public List<AccessConstraintDefinition> getAccessConstraints() {
                return rootResourceConstraints;
            }
        };
        ManagementResourceRegistration rootRegistration = ManagementResourceRegistration.Factory.forProcessType(ProcessType.EMBEDDED_SERVER).createRegistration(rootRd);
        rootRegistration.registerOperationHandler(WRITE_CONFIG_DEF, NoopOperationStepHandler.WITHOUT_RESULT, true);

        PathElement childPE = PathElement.pathElement("child");
        ResourceDefinition childRd = new SimpleResourceDefinition(childPE, new NonResolvingResourceDescriptionResolver()) {
            @Override
            public List<AccessConstraintDefinition> getAccessConstraints() {
                return childResourceConstraints;
            }
        };
        ManagementResourceRegistration childRegistration = rootRegistration.registerSubModel(childRd);
        rootTarget = TargetResource.forStandalone(PathAddress.EMPTY_ADDRESS, rootRegistration, Resource.Factory.create());
        childTarget = TargetResource.forStandalone(PathAddress.pathAddress(childPE), childRegistration, Resource.Factory.create());
    }
 
Example #3
Source File: PlatformMBeanResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
    super.registerChildren(resourceRegistration);
    resourceRegistration.registerSubModel(ClassLoadingResourceDefinition.INSTANCE);
    if (ManagementFactory.getCompilationMXBean() != null) {
        resourceRegistration.registerSubModel(CompilationResourceDefinition.INSTANCE);
    }
    resourceRegistration.registerSubModel(GarbageCollectorRootResourceDefinition.INSTANCE);
    resourceRegistration.registerSubModel(MemoryManagerRootResourceDefinition.INSTANCE);
    resourceRegistration.registerSubModel(MemoryResourceDefinition.INSTANCE);
    resourceRegistration.registerSubModel(MemoryPoolRootResourceDefinition.INSTANCE);
    resourceRegistration.registerSubModel(OperatingSystemResourceDefinition.INSTANCE);
    resourceRegistration.registerSubModel(RuntimeResourceDefinition.INSTANCE);
    resourceRegistration.registerSubModel(ThreadResourceDefinition.INSTANCE);

    resourceRegistration.registerSubModel(BufferPoolRootResourceDefinition.INSTANCE);
}
 
Example #4
Source File: InterleavedSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS);

    String module = context.getCurrentAddressValue();
    resource.getModel().get(MODULE.getName()).set(module);

    SimpleResourceDefinition subsystemResource = new SimpleResourceDefinition(
            PathElement.pathElement(SUBSYSTEM, module),
            new NonResolvingResourceDescriptionResolver(),
            new FakeSubsystemAddHandler(),
            ReloadRequiredRemoveStepHandler.INSTANCE
    ){
        @Override
        public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
            super.registerAttributes(resourceRegistration);
            resourceRegistration.registerReadOnlyAttribute(ATTRIBUTE_DEFINITION, null);
        }
    };
    rootRegistration.registerSubModel(subsystemResource);
}
 
Example #5
Source File: ModuleLoadingResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {

    super.registerOperations(resourceRegistration);

    final OperationDefinition definition = new SimpleOperationDefinitionBuilder("list-resource-loader-paths", getResourceDescriptionResolver())
            .addParameter(MODULE_NAME)
            .setRuntimeOnly()
            .setReplyType(ModelType.LIST)
            .setReplyValueType(ModelType.STRING)
            .setDeprecated(ModelVersion.create(1, 4, 0))
            .setReadOnly()
            .build();

     resourceRegistration.registerOperationHandler(definition, new ModuleLocationHandler());
     resourceRegistration.registerOperationHandler(ModuleInfoHandler.DEFINITION, ModuleInfoHandler.INSTANCE);
}
 
Example #6
Source File: ReadAttributeGroupTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(registration, processType);
    GlobalNotifications.registerGlobalNotifications(registration, processType);

    ManagementResourceRegistration basicResourceRegistration = registration.registerSubModel(
            new SimpleResourceDefinition(PathElement.pathElement("subsystem", "basicSubsystem"), new NonResolvingResourceDescriptionResolver()));
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("first", ModelType.STRING, "group1", false), null);
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("second", ModelType.STRING, "group1", false), null);
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("third", ModelType.STRING, "group2", false), null);
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("fourth", ModelType.STRING, "group2", true), null);
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("fifth", ModelType.STRING, "group1", true), null);
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("sixth", ModelType.STRING, "group2", false, false), null);
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("seventh", ModelType.STRING, "group2", false, true), ShowModelAliasReadHandler.INSTANCE);
    basicResourceRegistration.registerReadOnlyAttribute(TestUtils.createAttribute("eigth", ModelType.STRING, "group1", false, false, true), null);

    registration.registerOperationHandler(TestUtils.SETUP_OPERATION_DEF, new OperationStepHandler() {
        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final ModelNode model = new ModelNode();
            //Atttributes
            model.get("subsystem", "basicSubsystem", "first").set("configuration1");
            model.get("subsystem", "basicSubsystem", "second").set(new ValueExpression("${my.value}"));
            model.get("subsystem", "basicSubsystem", "third").set("configuration3");
            model.get("subsystem", "basicSubsystem", "fourth").set("runtime4");
            model.get("subsystem", "basicSubsystem", "fifth").set("runtime5");
            model.get("subsystem", "basicSubsystem", "sixth").set("configuration6");
            model.get("subsystem", "basicSubsystem", "seventh").set("alias7");
            createModel(context, model);
        }
    }
    );
}
 
Example #7
Source File: RealmDefinition.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);

    for (AttributeDefinition attrDef : ALL_ATTRIBUTES) {
        //TODO: use subclass of realmAttrHandler that can call RealmDefinition.validateTruststoreSetIfRequired
        resourceRegistration.registerReadWriteAttribute(attrDef, null, realmAttrHandler);
    }
}
 
Example #8
Source File: CachingRealmDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    AbstractWriteAttributeHandler write = new ElytronReloadRequiredWriteAttributeHandler(ATTRIBUTES);
    for (AttributeDefinition current : ATTRIBUTES) {
        resourceRegistration.registerReadWriteAttribute(current, null, write);
    }
}
 
Example #9
Source File: LdapConnectionResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);

    LdapConnectionWriteAttributeHandler writeHandler = new LdapConnectionWriteAttributeHandler();
    writeHandler.registerAttributes(resourceRegistration);
}
 
Example #10
Source File: AbstractSocketBindingResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    resourceRegistration.registerReadOnlyAttribute(NAME, null);
    resourceRegistration.registerReadWriteAttribute(INTERFACE, null, getInterfaceWriteAttributeHandler());
    resourceRegistration.registerReadWriteAttribute(PORT, null, getPortWriteAttributeHandler());
    resourceRegistration.registerReadWriteAttribute(FIXED_PORT, null, getFixedPortWriteAttributeHandler());
    resourceRegistration.registerReadWriteAttribute(MULTICAST_ADDRESS, null, getMulticastAddressWriteAttributeHandler());
    resourceRegistration.registerReadWriteAttribute(MULTICAST_PORT, null, getMulticastPortWriteAttributeHandler());
    resourceRegistration.registerReadWriteAttribute(CLIENT_MAPPINGS, null, getClientMappingsWriteAttributeHandler());

}
 
Example #11
Source File: ProfileResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
    super.registerOperations(resourceRegistration);
    resourceRegistration.registerOperationHandler(DESCRIBE, ProfileDescribeHandler.INSTANCE);
    resourceRegistration.registerOperationHandler(ProfileCloneHandler.DEFINITION, new ProfileCloneHandler(hostInfo, ignoredDomainResourceRegistry));
    resourceRegistration.registerOperationHandler(GenericModelDescribeOperationHandler.DEFINITION, ProfileModelDescribeHandler.INSTANCE);
}
 
Example #12
Source File: ConstrainedResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);
    resourceRegistration.registerReadWriteAttribute(PASSWORD, null, new BasicAttributeWriteHandler(PASSWORD));
    resourceRegistration.registerReadOnlyAttribute(SECURITY_DOMAIN, null);
    resourceRegistration.registerReadWriteAttribute(AUTHENTICATION_INFLOW, null, new BasicAttributeWriteHandler(AUTHENTICATION_INFLOW));
    resourceRegistration.registerReadOnlyAttribute(JNDI_NAME, null);
    resourceRegistration.registerReadWriteAttribute(NEW_CONNECTION_SQL, null, new BasicAttributeWriteHandler(NEW_CONNECTION_SQL));
}
 
Example #13
Source File: MemoryManagerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration registration) {
    super.registerAttributes(registration);
    registration.registerReadOnlyAttribute(PlatformMBeanConstants.OBJECT_NAME, MemoryManagerMXBeanAttributeHandler.INSTANCE);

    for (AttributeDefinition attribute : METRICS) {
        registration.registerMetric(attribute, MemoryManagerMXBeanAttributeHandler.INSTANCE);
    }
}
 
Example #14
Source File: AdvancedModifiableKeyStoreDecorator.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void register(ManagementResourceRegistration resourceRegistration, ResourceDescriptionResolver descriptionResolver) {
    resourceRegistration.registerOperationHandler(
            new SimpleOperationDefinitionBuilder(ElytronDescriptionConstants.OBTAIN_CERTIFICATE, descriptionResolver)
                    .setParameters(ALIAS, DOMAIN_NAMES, CERTIFICATE_AUTHORITY_ACCOUNT, AGREE_TO_TERMS_OF_SERVICE, STAGING, ALGORITHM, KEY_SIZE, CREDENTIAL_REFERENCE)
                    .setRuntimeOnly()
                    .build(),
            new ObtainCertificateHandler());
}
 
Example #15
Source File: ResourceBuilderRoot.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);
    for (AttributeBinding ab : builder.attributes) {
        ab.register(resourceRegistration);
    }
}
 
Example #16
Source File: MainKernelServicesImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected MainKernelServicesImpl(ServiceContainer container, ModelTestModelControllerService controllerService,
        StringConfigurationPersister persister, ManagementResourceRegistration rootRegistration,
        OperationValidator operationValidator, String mainSubsystemName, ExtensionRegistry extensionRegistry,
        ModelVersion legacyModelVersion, boolean successfulBoot, Throwable bootError,
        boolean registerTransformers, Class<?> testClass) {
    super(container, controllerService, persister, rootRegistration, operationValidator, mainSubsystemName, extensionRegistry,
            legacyModelVersion, successfulBoot, bootError, registerTransformers);
    this.testClass = testClass;
    //add mgmt worker
    ManagementWorkerService.installService(container.subTarget());
}
 
Example #17
Source File: ResourceBuilderRoot.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
    super.registerChildren(resourceRegistration);
    for (ResourceBuilderRoot child : builder.children) {
        resourceRegistration.registerSubModel(new BuilderResourceDefinition(child));
    }
}
 
Example #18
Source File: BaseNativeInterfaceResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    AttributeDefinition[] attributeDefinitions = getAttributeDefinitions();
    OperationStepHandler writeHandler = new ManagementWriteAttributeHandler(attributeDefinitions);
    for (AttributeDefinition attr : attributeDefinitions) {
        resourceRegistration.registerReadWriteAttribute(attr, null, writeHandler);
    }
}
 
Example #19
Source File: MetricsUndefinedValueUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void initModel(ManagementModel managementModel, Resource modelControllerResource) {
    ManagementResourceRegistration rootRegistration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(rootRegistration, processType);
    GlobalNotifications.registerGlobalNotifications(rootRegistration, processType);
    managementControllerResource = rootRegistration.registerSubModel(resourceDefinition);

    Resource rootResource = managementModel.getRootResource();
    rootResource.registerChild(resourceDefinition.getPathElement(), Resource.Factory.create());
}
 
Example #20
Source File: FilteredReadResourceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void initModel(ManagementModel managementModel) {
    ManagementResourceRegistration registration = managementModel.getRootResourceRegistration();
    GlobalOperationHandlers.registerGlobalOperations(registration, ProcessType.EMBEDDED_SERVER);

    GlobalNotifications.registerGlobalNotifications(registration, ProcessType.EMBEDDED_SERVER);

    registration.registerSubModel(new TestResourceDefinition(UNCONSTRAINED_RESOURCE));
    registration.registerSubModel(new TestResourceDefinition(SENSITIVE_CONSTRAINED_RESOURCE,
            MY_SENSITIVE_CONSTRAINT));
}
 
Example #21
Source File: CredentialStoreResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
    super.registerOperations(resourceRegistration);
    resourceRegistration.registerOperationHandler(RELOAD, CredentialStoreHandler.INSTANCE);
    resourceRegistration.registerOperationHandler(READ_ALIASES, CredentialStoreReadAliasesHandler.INSTANCE);
    if (isServerOrHostController(resourceRegistration)) {
        resourceRegistration.registerOperationHandler(ADD_ALIAS, CredentialStoreHandler.INSTANCE);
        resourceRegistration.registerOperationHandler(REMOVE_ALIAS, CredentialStoreHandler.INSTANCE);
        resourceRegistration.registerOperationHandler(SET_SECRET, CredentialStoreHandler.INSTANCE);
    }
}
 
Example #22
Source File: BaseHttpInterfaceResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    AttributeDefinition[] attributeDefinitions = getAttributeDefinitions();
    OperationStepHandler defaultWriteHandler = new ManagementWriteAttributeHandler(attributeDefinitions, getValidationConsumer());
    for (AttributeDefinition attr : attributeDefinitions) {
        if (attr.equals(HTTP_UPGRADE_ENABLED)) {
            HttpUpgradeAttributeHandler handler = new HttpUpgradeAttributeHandler();
            resourceRegistration.registerReadWriteAttribute(attr, handler, handler);
        } else {
            resourceRegistration.registerReadWriteAttribute(attr, null, defaultWriteHandler);
        }
    }
}
 
Example #23
Source File: ModifiableRealmDecorator.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void register(ManagementResourceRegistration resourceRegistration, ResourceDescriptionResolver descriptionResolver) {
    resourceRegistration.registerOperationHandler(
            new SimpleOperationDefinitionBuilder(ElytronDescriptionConstants.ADD_IDENTITY_ATTRIBUTE, descriptionResolver)
                    .setParameters(IDENTITY, NAME, VALUES)
                    .setRuntimeOnly()
                    .build(),
            new AddIdentityAttributeHandler());
}
 
Example #24
Source File: PathResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    resourceRegistration.registerReadOnlyAttribute(NAME, ReadResourceNameOperationStepHandler.INSTANCE);
    resourceRegistration.registerReadWriteAttribute(RELATIVE_TO_LOCAL, null, new PathWriteAttributeHandler(pathManager, RELATIVE_TO_LOCAL));
    SimpleAttributeDefinition pathAttr = specified ? PATH_SPECIFIED : PATH_NAMED;
    resourceRegistration.registerReadWriteAttribute(pathAttr, null, new PathWriteAttributeHandler(pathManager, pathAttr));
    resourceRegistration.registerReadOnlyAttribute(READ_ONLY, null);
}
 
Example #25
Source File: RootLoggerResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerOperations(ManagementResourceRegistration registration) {
    super.registerOperations(registration);

    registration.registerOperationHandler(ADD_ROOT_LOGGER_DEFINITION, addHandler);
    registration.registerOperationHandler(ROOT_LOGGER_REMOVE_OPERATION, LoggerOperations.REMOVE_LOGGER);
    registration.registerOperationHandler(CHANGE_LEVEL_OPERATION, LoggerOperations.CHANGE_LEVEL);
    registration.registerOperationHandler(ADD_HANDLER_OPERATION, LoggerOperations.ADD_HANDLER);
    registration.registerOperationHandler(REMOVE_HANDLER_OPERATION, LoggerOperations.REMOVE_HANDLER);
    registration.registerOperationHandler(LEGACY_ADD_HANDLER_OPERATION, LoggerOperations.ADD_HANDLER);
    registration.registerOperationHandler(LEGACY_REMOVE_HANDLER_OPERATION, LoggerOperations.REMOVE_HANDLER);
}
 
Example #26
Source File: CertificateAuthorityAccountDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void register(ManagementResourceRegistration resourceRegistration, ResourceDescriptionResolver descriptionResolver) {
    resourceRegistration.registerOperationHandler(
            new SimpleOperationDefinitionBuilder(ElytronDescriptionConstants.UPDATE_ACCOUNT, descriptionResolver)
                    .setParameters(AGREE_TO_TERMS_OF_SERVICE, STAGING)
                    .setRuntimeOnly()
                    .build(),
            new CertificateAuthorityAccountDefinition.UpdateAccountHandler());
}
 
Example #27
Source File: SecureDeploymentDefinition.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);
    for (AttributeDefinition attrDef : ALL_ATTRIBUTES) {
        resourceRegistration.registerReadWriteAttribute(attrDef, null, attrHandler);
    }
}
 
Example #28
Source File: ConnectorResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
    for (AttributeDefinition ad : ATTRIBUTES) {
        resourceRegistration.registerReadWriteAttribute(ad, null, writeHandler);
    }
}
 
Example #29
Source File: ModifiableRealmDecorator.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void register(ManagementResourceRegistration resourceRegistration, ResourceDescriptionResolver descriptionResolver) {
    resourceRegistration.registerOperationHandler(
            new SimpleOperationDefinitionBuilder(ElytronDescriptionConstants.ADD_IDENTITY, descriptionResolver)
                    .setParameters(IDENTITY)
                    .setRuntimeOnly()
                    .build(),
            new AddIdentityHandler());
}
 
Example #30
Source File: ModelControllerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
ManagementModelImpl(final ManagementResourceRegistration resourceRegistration,
                            final Resource rootResource,
                            final CapabilityRegistry capabilityRegistry) {
            this.resourceRegistration = resourceRegistration;
            this.rootResource = rootResource;
            assert capabilityRegistry != null;
            this.capabilityRegistry = capabilityRegistry;
            // What we expose depends on the state of our 'published' field. If 'true' we've been published
            // to the ModelController, and from then on callers should get whatever the MC has as current.
            // If 'false' we haven't been published; we are a local copy created by some OperationContext,
            // so callers should see our local members

            // TODO use this if we ever actually support cloning the MRR
//            this.delegatingResourceRegistration = new DelegatingManagementResourceRegistration(new DelegatingManagementResourceRegistration.RegistrationDelegateProvider() {
//                @Override
//                public ManagementResourceRegistration getDelegateRegistration() {
//                    ManagementResourceRegistration result;
//                    if (published) {
//                        result = ModelControllerImpl.this.managementModel.get().resourceRegistration;
//                    } else {
//                        result = resourceRegistration;
//                    }
//                    return result;
//                }
//            });
            this.delegatingResourceRegistration = resourceRegistration;
            this.delegatingResource = new DelegatingResource(new DelegatingResource.ResourceDelegateProvider() {
                @Override
                public Resource getDelegateResource() {
                    Resource result;
                    if (published) {
                        result = ModelControllerImpl.this.managementModel.get().rootResource;
                    } else {
                        result = rootResource;
                    }
                    return result;
                }
            });
        }