Search in sources :

Example 61 with AttributeDefinition

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

the class JcaWorkManagerDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);
    for (final WmParameters parameter : WmParameters.values()) {
        AttributeDefinition ad = parameter.getAttribute();
        resourceRegistration.registerReadOnlyAttribute(ad, ReadResourceNameOperationStepHandler.INSTANCE);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition)

Example 62 with AttributeDefinition

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

the class IIOPSubsystemAdd method getResourceProperties.

private void getResourceProperties(final Properties properties, PersistentResourceDefinition resource, OperationContext context, ModelNode model) throws OperationFailedException {
    for (AttributeDefinition attrDefinition : resource.getAttributes()) {
        if (attrDefinition instanceof PropertiesAttributeDefinition) {
            PropertiesAttributeDefinition pad = (PropertiesAttributeDefinition) attrDefinition;
            ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
            if (resolvedModelAttribute.isDefined()) {
                for (final Property prop : resolvedModelAttribute.asPropertyList()) {
                    properties.setProperty(prop.getName(), prop.getValue().asString());
                }
            }
            continue;
        }
        ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
        //FIXME
        if (resolvedModelAttribute.isDefined()) {
            String name = attrDefinition.getName();
            String value = resolvedModelAttribute.asString();
            String openjdkProperty = PropertiesMap.PROPS_MAP.get(name);
            if (openjdkProperty != null) {
                name = openjdkProperty;
            }
            properties.setProperty(name, value);
        }
    }
}
Also used : PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 63 with AttributeDefinition

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

the class IDMConfigAddStepHandler method configureModelValidators.

private void configureModelValidators(ModelValidationStepHandler[] modelValidators) {
    List<AttributeDefinition> alternativeAttributes = new ArrayList<AttributeDefinition>();
    for (AttributeDefinition attribute : this.attributes) {
        if (attribute.getAlternatives() != null && attribute.getAlternatives().length > 0) {
            alternativeAttributes.add(attribute);
        }
    }
    if (!alternativeAttributes.isEmpty()) {
        this.modelValidators.add(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()]), isAlternativesRequired()));
    }
    if (modelValidators != null) {
        this.modelValidators.addAll(Arrays.asList(modelValidators));
    }
    this.modelValidators.add(new ModelValidationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
            Resource resource = context.readResourceFromRoot(address);
            final ModelNode parentModel = Resource.Tools.readModel(resource);
            PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
            context.stepCompleted();
        }
    });
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.ModelValidationStepHandler) ModelNode(org.jboss.dmr.ModelNode) AlternativeAttributeValidationStepHandler(org.wildfly.extension.picketlink.common.model.validator.AlternativeAttributeValidationStepHandler)

Example 64 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project camunda-bpm-platform by camunda.

the class CustomMarshaller method getValueType.

/**
 * Obtain the 'valueType' of the ObjectListAttributeDefinition through reflection because they are private in Wildfly 8.
 */
public static AttributeDefinition getValueType(Object instance, Class clazz) {
    try {
        Field valueTypesField = clazz.getDeclaredField("valueType");
        valueTypesField.setAccessible(true);
        Object value = valueTypesField.get(instance);
        if (value != null) {
            if (AttributeDefinition.class.isAssignableFrom(value.getClass())) {
                return (AttributeDefinition) value;
            }
        }
        return (AttributeDefinition) value;
    } catch (Exception e) {
        throw new RuntimeException("Unable to get valueType.", e);
    }
}
Also used : Field(java.lang.reflect.Field) ObjectListAttributeDefinition(org.jboss.as.controller.ObjectListAttributeDefinition) ObjectTypeAttributeDefinition(org.jboss.as.controller.ObjectTypeAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 65 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project camunda-bpm-platform by camunda.

the class CustomMarshaller method getValueTypes.

/**
 * Obtain the 'valueTypes' of the ObjectTypeAttributeDefinition through reflection because they are private in Wildfly 8.
 */
public static AttributeDefinition[] getValueTypes(Object instance, Class clazz) {
    try {
        if (ObjectTypeAttributeDefinition.class.isAssignableFrom(clazz)) {
            Field valueTypesField = clazz.getDeclaredField("valueTypes");
            valueTypesField.setAccessible(true);
            Object value = valueTypesField.get(instance);
            if (value != null) {
                if (AttributeDefinition[].class.isAssignableFrom(value.getClass())) {
                    return (AttributeDefinition[]) value;
                }
            }
            return (AttributeDefinition[]) value;
        }
    } catch (Exception e) {
        throw new RuntimeException("Unable to get valueTypes.", e);
    }
    return null;
}
Also used : Field(java.lang.reflect.Field) ObjectListAttributeDefinition(org.jboss.as.controller.ObjectListAttributeDefinition) ObjectTypeAttributeDefinition(org.jboss.as.controller.ObjectTypeAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) XMLStreamException(javax.xml.stream.XMLStreamException)

Aggregations

AttributeDefinition (org.jboss.as.controller.AttributeDefinition)102 ModelNode (org.jboss.dmr.ModelNode)48 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)40 PathAddress (org.jboss.as.controller.PathAddress)17 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)16 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)14 OperationContext (org.jboss.as.controller.OperationContext)13 Resource (org.jboss.as.controller.registry.Resource)12 Property (org.jboss.dmr.Property)12 ObjectTypeAttributeDefinition (org.jboss.as.controller.ObjectTypeAttributeDefinition)9 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)9 StringListAttributeDefinition (org.jboss.as.controller.StringListAttributeDefinition)9 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 ArrayList (java.util.ArrayList)7 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)6 Map (java.util.Map)5 AbstractAddStepHandler (org.jboss.as.controller.AbstractAddStepHandler)5 SimpleListAttributeDefinition (org.jboss.as.controller.SimpleListAttributeDefinition)5 SimpleOperationDefinitionBuilder (org.jboss.as.controller.SimpleOperationDefinitionBuilder)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5