Search in sources :

Example 66 with AttributeDefinition

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

the class CamelRootResource method registerChildren.

@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
    resourceRegistration.registerSubModel(new CamelContextResource(subsystemState));
    if (registerRuntimeOnly) {
        AttributeDefinition eldef = new SimpleAttributeDefinitionBuilder("dummy", ModelType.STRING, false).build();
        AttributeDefinition attdef = new SimpleListAttributeDefinition.Builder(ModelConstants.ENDPOINTS, eldef).setStorageRuntime().build();
        resourceRegistration.registerReadOnlyAttribute(attdef, new CamelRuntimeOnlyHandler());
    }
}
Also used : SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) SimpleListAttributeDefinition(org.jboss.as.controller.SimpleListAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder)

Example 67 with AttributeDefinition

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

the class IdentityResourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    outflowSecurityDomains.clear();
    ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
    for (AttributeDefinition attribute : ATTRIBUTES) {
        resourceRegistration.registerReadWriteAttribute(attribute, null, handler);
    }
}
Also used : StringListAttributeDefinition(org.jboss.as.controller.StringListAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 68 with AttributeDefinition

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

the class JaxrsSubsystemParser_2_0 method writeContent.

/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter streamWriter, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(NAMESPACE, false);
    ModelNode subsystem = context.getModelNode();
    for (AttributeDefinition attr : JaxrsAttribute.ATTRIBUTES) {
        attr.marshallAsElement(subsystem, true, streamWriter);
    }
    streamWriter.writeEndElement();
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 69 with AttributeDefinition

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

the class JacORBExtension method registerTransformers.

/**
 * Register the transformers for the 1.3.0 version.
 *
 * @param subsystem the subsystems registration
 */
protected static void registerTransformers(final SubsystemRegistration subsystem) {
    ChainedTransformationDescriptionBuilder chained = ResourceTransformationDescriptionBuilder.Factory.createChainedSubystemInstance(CURRENT_MODEL_VERSION);
    ModelVersion MODEL_VERSION_EAP64 = ModelVersion.create(1, 4, 0);
    // also EAP6.2
    ModelVersion MODEL_VERSION_EAP63 = ModelVersion.create(1, 3, 0);
    ResourceTransformationDescriptionBuilder builder64 = chained.createBuilder(CURRENT_MODEL_VERSION, MODEL_VERSION_EAP64);
    builder64.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, JacORBSubsystemDefinitions.PERSISTENT_SERVER_ID).setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, JacORBSubsystemDefinitions.PERSISTENT_SERVER_ID).setValueConverter(AttributeConverter.DEFAULT_VALUE, JacORBSubsystemDefinitions.INTEROP_CHUNK_RMI_VALUETYPES);
    ResourceTransformationDescriptionBuilder builder63 = chained.createBuilder(MODEL_VERSION_EAP64, MODEL_VERSION_EAP63);
    builder63.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, IORTransportConfigDefinition.ATTRIBUTES.toArray(new AttributeDefinition[0])).addRejectCheck(RejectAttributeChecker.DEFINED, IORASContextDefinition.ATTRIBUTES.toArray(new AttributeDefinition[0])).addRejectCheck(RejectAttributeChecker.DEFINED, IORSASContextDefinition.ATTRIBUTES.toArray(new AttributeDefinition[0])).end().rejectChildResource(IORSettingsDefinition.INSTANCE.getPathElement());
    chained.buildAndRegister(subsystem, new ModelVersion[] { MODEL_VERSION_EAP64, MODEL_VERSION_EAP63 });
}
Also used : ChainedTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ChainedTransformationDescriptionBuilder) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelVersion(org.jboss.as.controller.ModelVersion)

Example 70 with AttributeDefinition

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

the class MessagingSubsystemParser method parseSecurityRoles.

private void parseSecurityRoles(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> operations) throws XMLStreamException {
    final Map<String, Set<AttributeDefinition>> permsByRole = new HashMap<String, Set<AttributeDefinition>>();
    String localName = null;
    do {
        reader.nextTag();
        localName = reader.getLocalName();
        final Element element = Element.forName(localName);
        if (element != Element.PERMISSION_ELEMENT_NAME) {
            break;
        }
        final Set<Attribute> required = EnumSet.of(Attribute.ROLES_ATTR_NAME, Attribute.TYPE_ATTR_NAME);
        List<String> roles = null;
        AttributeDefinition perm = null;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            requireNoNamespaceAttribute(reader, i);
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch(attribute) {
                case ROLES_ATTR_NAME:
                    roles = parseRolesAttribute(reader, i);
                    break;
                case TYPE_ATTR_NAME:
                    perm = SecurityRoleDefinition.ROLE_ATTRIBUTES_BY_XML_NAME.get(reader.getAttributeValue(i));
                    if (perm == null) {
                        throw ControllerLogger.ROOT_LOGGER.invalidAttributeValue(reader.getAttributeValue(i), reader.getAttributeName(i), SecurityRoleDefinition.ROLE_ATTRIBUTES_BY_XML_NAME.keySet(), reader.getLocation());
                    }
                    break;
                default:
                    throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
        if (!required.isEmpty()) {
            throw missingRequired(reader, required);
        }
        for (String role : roles) {
            role = role.trim();
            Set<AttributeDefinition> perms = permsByRole.get(role);
            if (perms == null) {
                perms = new HashSet<AttributeDefinition>();
                permsByRole.put(role, perms);
            }
            perms.add(perm);
        }
        // Scan to element end
        reader.discardRemainder();
    } while (reader.hasNext());
    for (Map.Entry<String, Set<AttributeDefinition>> entry : permsByRole.entrySet()) {
        final String role = entry.getKey();
        final Set<AttributeDefinition> perms = entry.getValue();
        final ModelNode addr = address.clone();
        addr.add(ROLE, role);
        final ModelNode operation = new ModelNode();
        operation.get(OP).set(ADD);
        operation.get(OP_ADDR).set(addr);
        for (AttributeDefinition perm : SecurityRoleDefinition.ATTRIBUTES) {
            operation.get(perm.getName()).set(perms.contains(perm));
        }
        operations.add(operation);
    }
}
Also used : EnumSet(java.util.EnumSet) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ParseUtils.requireSingleAttribute(org.jboss.as.controller.parsing.ParseUtils.requireSingleAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.readStringAttributeElement(org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ParseUtils.unexpectedEndElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedEndElement) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ListAttributeDefinition(org.jboss.as.controller.ListAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map) HashMap(java.util.HashMap)

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