Search in sources :

Example 31 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class QueueDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration registry) {
    super.registerAttributes(registry);
    for (SimpleAttributeDefinition attr : ATTRIBUTES) {
        if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
            if (isRuntime()) {
                AttributeDefinition readOnlyRuntimeAttr = create(attr).setStorageRuntime().build();
                registry.registerReadOnlyAttribute(readOnlyRuntimeAttr, QueueReadAttributeHandler.RUNTIME_INSTANCE);
            } else {
                registry.registerReadOnlyAttribute(attr, null);
            }
        }
    }
    for (AttributeDefinition attr : READONLY_ATTRIBUTES) {
        registry.registerReadOnlyAttribute(attr, QueueReadAttributeHandler.INSTANCE);
    }
    for (AttributeDefinition metric : METRICS) {
        registry.registerMetric(metric, QueueReadAttributeHandler.INSTANCE);
    }
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition)

Example 32 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class SecurityRoleDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration registry) {
    super.registerAttributes(registry);
    if (runtimeOnly) {
        for (SimpleAttributeDefinition attr : ATTRIBUTES) {
            AttributeDefinition readOnlyAttr = SimpleAttributeDefinitionBuilder.create(attr).setStorageRuntime().build();
            registry.registerReadOnlyAttribute(readOnlyAttr, SecurityRoleReadAttributeHandler.INSTANCE);
        }
    } else {
        for (AttributeDefinition attr : ATTRIBUTES) {
            if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
                registry.registerReadWriteAttribute(attr, null, SecurityRoleAttributeHandler.INSTANCE);
            }
        }
    }
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ObjectTypeAttributeDefinition(org.jboss.as.controller.ObjectTypeAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition)

Example 33 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class AbstractFederationResourceDefinition method createAttributeWriterHandler.

@Override
protected OperationStepHandler createAttributeWriterHandler() {
    List<SimpleAttributeDefinition> attributes = getAttributes();
    final List<AttributeDefinition> alternativeAttributes = getAlternativesAttributes();
    return new ReloadRequiredWriteAttributeHandler(attributes.toArray(new AttributeDefinition[attributes.size()])) {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            if (!alternativeAttributes.isEmpty()) {
                context.addStep(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()])), OperationContext.Stage.MODEL);
            }
            doRegisterModelWriteAttributeHandler(context, operation);
            super.execute(context, operation);
        }
    };
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler) AlternativeAttributeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)

Example 34 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class AlternativeAttributeValidationStepHandler method validateAlternatives.

protected void validateAlternatives(OperationContext context, ModelNode operation) throws OperationFailedException {
    ModelNode elementNode = context.readResource(EMPTY_ADDRESS, false).getModel();
    PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    ModelNode definedAttribute = null;
    for (AttributeDefinition attribute : this.attributes) {
        if (elementNode.hasDefined(attribute.getName())) {
            if (definedAttribute != null) {
                throw ROOT_LOGGER.invalidAlternativeAttributeOccurrence(attribute.getName(), address.getLastElement().toString(), getAttributeNames());
            }
            definedAttribute = attribute.resolveModelAttribute(context, elementNode);
        }
    }
    if (this.required && definedAttribute == null) {
        throw ROOT_LOGGER.requiredAlternativeAttributes(address.getLastElement().toString(), getAttributeNames());
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 35 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class AbstractIDMResourceDefinition method createAttributeWriterHandler.

@Override
protected OperationStepHandler createAttributeWriterHandler() {
    List<SimpleAttributeDefinition> attributes = getAttributes();
    final List<AttributeDefinition> alternativeAttributes = getAlternativesAttributes();
    return new IDMConfigWriteAttributeHandler(attributes.toArray(new AttributeDefinition[attributes.size()])) {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            if (!alternativeAttributes.isEmpty()) {
                context.addStep(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()])), OperationContext.Stage.MODEL);
            }
            doRegisterModelWriteAttributeHandler(context, operation);
            super.execute(context, operation);
        }
    };
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) AlternativeAttributeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)

Aggregations

AttributeDefinition (org.jboss.as.controller.AttributeDefinition)79 ModelNode (org.jboss.dmr.ModelNode)43 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)33 OperationContext (org.jboss.as.controller.OperationContext)16 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)12 PathAddress (org.jboss.as.controller.PathAddress)12 Resource (org.jboss.as.controller.registry.Resource)11 Property (org.jboss.dmr.Property)11 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)10 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 AbstractAddStepHandler (org.jboss.as.controller.AbstractAddStepHandler)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 PathElement (org.jboss.as.controller.PathElement)5 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)5 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)5 StringListAttributeDefinition (org.jboss.as.controller.StringListAttributeDefinition)5 SecurityDomainContext (org.jboss.as.security.plugins.SecurityDomainContext)5 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5