Search in sources :

Example 31 with SimpleAttributeDefinition

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

the class XaDataSourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    if (deployed) {
        for (final SimpleAttributeDefinition attribute : XA_DATASOURCE_ATTRIBUTE) {
            SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
        }
        for (final PropertiesAttributeDefinition attribute : XA_DATASOURCE_PROPERTIES_ATTRIBUTES) {
            PropertiesAttributeDefinition runtimeAttribute = new PropertiesAttributeDefinition.Builder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
        }
    } else {
        ReloadRequiredWriteAttributeHandler reloadRequiredWriteHandler = new ReloadRequiredWriteAttributeHandler(XA_DATASOURCE_ATTRIBUTE);
        for (final SimpleAttributeDefinition attribute : XA_DATASOURCE_ATTRIBUTE) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else if (attribute.getName().equals(ENLISTMENT_TRACE.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, null, new EnlistmentTraceAttributeWriteHandler());
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredWriteHandler);
            }
        }
        ReloadRequiredWriteAttributeHandler reloadRequiredPropertiesWriteHandler = new ReloadRequiredWriteAttributeHandler(XA_DATASOURCE_PROPERTIES_ATTRIBUTES);
        for (final PropertiesAttributeDefinition attribute : XA_DATASOURCE_PROPERTIES_ATTRIBUTES) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredPropertiesWriteHandler);
            }
        }
    }
}
Also used : PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 32 with SimpleAttributeDefinition

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

the class XaDataSourcePropertyDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    if (deployed) {
        SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(Constants.XADATASOURCE_PROPERTY_VALUE).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
        resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
    } else {
        resourceRegistration.registerReadOnlyAttribute(Constants.XADATASOURCE_PROPERTY_VALUE, null);
    }
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder)

Example 33 with SimpleAttributeDefinition

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

the class JacORBSubsystemParser method parseSecurityConfig_1_0.

/**
 * <p>
 * Parses the {@code security} section of the JacORB subsystem configuration according to the XSD version 1.0.
 * </p>
 *
 * @param reader the {@code XMLExtendedStreamReader} used to read the configuration XML.
 * @param node   the {@code ModelNode} that will hold the parsed security configuration.
 * @throws javax.xml.stream.XMLStreamException
 *          if an error occurs while parsing the XML.
 */
private void parseSecurityConfig_1_0(XMLExtendedStreamReader reader, ModelNode node) throws XMLStreamException {
    // parse all security attributes.
    EnumSet<Attribute> expectedAttributes = EnumSet.of(Attribute.SECURITY_SUPPORT_SSL, Attribute.SECURITY_ADD_COMPONENT_INTERCEPTOR, Attribute.SECURITY_CLIENT_SUPPORTS, Attribute.SECURITY_CLIENT_REQUIRES, Attribute.SECURITY_SERVER_SUPPORTS, Attribute.SECURITY_SERVER_REQUIRES, Attribute.SECURITY_USE_DOMAIN_SF, Attribute.SECURITY_USE_DOMAIN_SSF);
    EnumSet<Attribute> parsedAttributes = EnumSet.noneOf(Attribute.class);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        requireNoNamespaceAttribute(reader, i);
        String attrValue = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        // check for unexpected attributes.
        if (!expectedAttributes.contains(attribute))
            throw unexpectedAttribute(reader, i);
        // check for duplicate attributes.
        if (!parsedAttributes.add(attribute)) {
            throw duplicateAttribute(reader, attribute.getLocalName());
        }
        switch(attribute) {
            // check the attributes that need to be converted from int to string.
            case SECURITY_CLIENT_SUPPORTS:
            case SECURITY_CLIENT_REQUIRES:
            case SECURITY_SERVER_SUPPORTS:
            case SECURITY_SERVER_REQUIRES:
                SSLConfigValue value = SSLConfigValue.fromValue(attrValue);
                if (value == null)
                    throw JacORBLogger.ROOT_LOGGER.invalidSSLConfig(attrValue, reader.getLocation());
                attrValue = value.toString();
            default:
                SimpleAttributeDefinition definition = ((SimpleAttributeDefinition) JacORBSubsystemDefinitions.valueOf(attribute.getLocalName()));
                // a null definition represents an attribute that has been deprecated and is no longer used.
                if (definition != null)
                    definition.parseAndSetParameter(attrValue, node, reader);
        }
    }
    // the security element doesn't have child elements.
    requireNoContent(reader);
}
Also used : ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ParseUtils.duplicateAttribute(org.jboss.as.controller.parsing.ParseUtils.duplicateAttribute) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition)

Example 34 with SimpleAttributeDefinition

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

the class MessagingSubsystemParser method processHornetQServer.

protected void processHornetQServer(final XMLExtendedStreamReader reader, final ModelNode subsystemAddress, final List<ModelNode> list, Namespace namespace) throws XMLStreamException {
    String hqServerName = null;
    String elementName = null;
    if (namespace == Namespace.MESSAGING_1_0) {
        // We're parsing the 1.0 xsd's <subsystem> element
        requireNoAttributes(reader);
        elementName = ModelDescriptionConstants.SUBSYSTEM;
    } else {
        final int count = reader.getAttributeCount();
        if (count > 0) {
            requireSingleAttribute(reader, Attribute.NAME.getLocalName());
            hqServerName = reader.getAttributeValue(0).trim();
        }
        elementName = HORNETQ_SERVER;
    }
    if (hqServerName == null || hqServerName.length() == 0) {
        hqServerName = DEFAULT;
    }
    final ModelNode address = subsystemAddress.clone();
    address.add(HORNETQ_SERVER, hqServerName);
    address.protect();
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    operation.get(OP_ADDR).set(address);
    list.add(operation);
    EnumSet<Element> seen = EnumSet.noneOf(Element.class);
    // Handle elements
    String localName = null;
    do {
        reader.nextTag();
        localName = reader.getLocalName();
        final Element element = Element.forName(reader.getLocalName());
        if (!seen.add(element)) {
            throw ParseUtils.duplicateNamedElement(reader, element.getLocalName());
        }
        switch(element) {
            case ACCEPTORS:
                processAcceptors(reader, address, list);
                break;
            case ADDRESS_SETTINGS:
                processAddressSettings(reader, address, list);
                break;
            case BINDINGS_DIRECTORY:
                parseDirectory(reader, CommonAttributes.BINDINGS_DIRECTORY, address, list);
                break;
            case BRIDGES:
                processBridges(reader, address, list);
                break;
            case BROADCAST_GROUPS:
                processBroadcastGroups(reader, address, list);
                break;
            case CLUSTER_CONNECTIONS:
                processClusterConnections(reader, address, list);
                break;
            case CONNECTORS:
                processConnectors(reader, address, list);
                break;
            case CONNECTOR_SERVICES:
                processConnectorServices(reader, address, list);
                break;
            case DISCOVERY_GROUPS:
                processDiscoveryGroups(reader, address, list);
                break;
            case DIVERTS:
                parseDiverts(reader, address, list);
                break;
            case FILE_DEPLOYMENT_ENABLED:
                // This isn't an element in the xsd as there is no filesystem support in AS
                unhandledElement(reader, element);
                break;
            case GROUPING_HANDLER:
                processGroupingHandler(reader, address, list);
                break;
            case JOURNAL_DIRECTORY:
                parseDirectory(reader, CommonAttributes.JOURNAL_DIRECTORY, address, list);
                break;
            case LARGE_MESSAGES_DIRECTORY:
                parseDirectory(reader, CommonAttributes.LARGE_MESSAGES_DIRECTORY, address, list);
                break;
            case LIVE_CONNECTOR_REF:
                {
                    MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
                    skipElementText(reader);
                    break;
                }
            case PAGING_DIRECTORY:
                parseDirectory(reader, CommonAttributes.PAGING_DIRECTORY, address, list);
                break;
            case REMOTING_INTERCEPTORS:
                processRemotingInterceptors(reader, operation);
                break;
            case SECURITY_DOMAIN:
                handleElementText(reader, element, null, operation);
                break;
            case SECURITY_SETTINGS:
                {
                    // process security settings
                    processSecuritySettings(reader, address, list);
                    break;
                }
            case CORE_QUEUES:
                {
                    parseQueues(reader, address, list);
                    break;
                }
            case CONNECTION_FACTORIES:
                {
                    processConnectionFactories(reader, address, list);
                    break;
                }
            case JMS_DESTINATIONS:
                {
                    processJmsDestinations(reader, address, list);
                    break;
                }
            case SCHEDULED_THREAD_POOL_MAX_SIZE:
            case THREAD_POOL_MAX_SIZE:
                {
                    // Use the "server" variant
                    handleElementText(reader, element, "server", operation);
                    break;
                }
            case MESSAGE_COUNTER_ENABLED:
                {
                    MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString(), Element.STATISTICS_ENABLED.toString());
                    handleElementText(reader, element, operation);
                    break;
                }
            case HORNETQ_SERVER:
                // The end of the hornetq-server element
                if (namespace == Namespace.MESSAGING_1_0) {
                    throw unexpectedEndElement(reader);
                }
                break;
            case SUBSYSTEM:
                // The end of the subsystem element
                if (namespace != Namespace.MESSAGING_1_0) {
                    throw unexpectedEndElement(reader);
                }
                break;
            case CLUSTERED:
                // log that the attribute is deprecated but handle it anyway
                MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
            default:
                if (SIMPLE_ROOT_RESOURCE_ELEMENTS.contains(element)) {
                    AttributeDefinition attributeDefinition = element.getDefinition();
                    if (attributeDefinition instanceof SimpleAttributeDefinition) {
                        handleElementText(reader, element, operation);
                    } else {
                        // These should be handled in specific case blocks above, e.g. case REMOTING_INTERCEPTORS:
                        handleComplexConfigurationAttribute(reader, element, operation);
                    }
                } else {
                    handleUnknownConfigurationAttribute(reader, element, operation);
                }
        }
    } while (reader.hasNext() && localName.equals(elementName) == false);
}
Also used : 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) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 35 with SimpleAttributeDefinition

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

the class PooledConnectionFactoryDefinition method copy.

private static AttributeDefinition copy(AttributeDefinition attribute, AttributeAccess.Flag flag) {
    AbstractAttributeDefinitionBuilder builder;
    if (attribute instanceof SimpleListAttributeDefinition) {
        builder = new SimpleListAttributeDefinition.Builder((SimpleListAttributeDefinition) attribute);
        // TODO remove once WFCORE-95 is fixed
        ((SimpleListAttributeDefinition.Builder) builder).setListValidator(attribute.getValidator());
    } else if (attribute instanceof SimpleMapAttributeDefinition) {
        builder = new SimpleMapAttributeDefinition.Builder((SimpleMapAttributeDefinition) attribute);
    } else if (attribute instanceof PrimitiveListAttributeDefinition) {
        builder = new PrimitiveListAttributeDefinition.Builder((PrimitiveListAttributeDefinition) attribute);
        // TODO remove once WFCORE-95 is fixed
        ((PrimitiveListAttributeDefinition.Builder) builder).setListValidator(attribute.getValidator());
    } else {
        builder = new SimpleAttributeDefinitionBuilder((SimpleAttributeDefinition) attribute);
    }
    builder.setFlags(flag);
    return builder.build();
}
Also used : SimpleListAttributeDefinition(org.jboss.as.controller.SimpleListAttributeDefinition) AbstractAttributeDefinitionBuilder(org.jboss.as.controller.AbstractAttributeDefinitionBuilder) AbstractAttributeDefinitionBuilder(org.jboss.as.controller.AbstractAttributeDefinitionBuilder) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) SimpleMapAttributeDefinition(org.jboss.as.controller.SimpleMapAttributeDefinition) PrimitiveListAttributeDefinition(org.jboss.as.controller.PrimitiveListAttributeDefinition)

Aggregations

SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)45 ModelNode (org.jboss.dmr.ModelNode)15 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)11 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)9 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)9 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)8 Property (org.jboss.dmr.Property)6 OperationContext (org.jboss.as.controller.OperationContext)4 AbstractAttributeDefinitionBuilder (org.jboss.as.controller.AbstractAttributeDefinitionBuilder)3 PathAddress (org.jboss.as.controller.PathAddress)3 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)3 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)3 SimpleListAttributeDefinition (org.jboss.as.controller.SimpleListAttributeDefinition)3 SimpleMapAttributeDefinition (org.jboss.as.controller.SimpleMapAttributeDefinition)3 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)3 ClearWorkManagerStatisticsHandler (org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)2 WorkManagerRuntimeAttributeReadHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler)2 WorkManagerRuntimeAttributeWriteHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeWriteHandler)2 AbstractWriteAttributeHandler (org.jboss.as.controller.AbstractWriteAttributeHandler)2 ListAttributeDefinition (org.jboss.as.controller.ListAttributeDefinition)2