Search in sources :

Example 6 with AttributeDefinition

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

the class MessagingXMLWriter method writeConnectorServices.

private static void writeConnectorServices(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.CONNECTOR_SERVICES.getLocalName());
        for (final Property property : node.asPropertyList()) {
            writer.writeStartElement(Element.CONNECTOR_SERVICE.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
            final ModelNode service = property.getValue();
            for (AttributeDefinition attribute : ConnectorServiceDefinition.ATTRIBUTES) {
                attribute.marshallAsElement(property.getValue(), writer);
            }
            // TODO use a custom attribute marshaller
            if (service.hasDefined(CommonAttributes.PARAM)) {
                for (Property param : service.get(CommonAttributes.PARAM).asPropertyList()) {
                    writer.writeEmptyElement(Element.PARAM.getLocalName());
                    writer.writeAttribute(Attribute.KEY.getLocalName(), param.getName());
                    writer.writeAttribute(Attribute.VALUE.getLocalName(), param.getValue().get(ConnectorServiceParamDefinition.VALUE.getName()).asString());
                }
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
        writeNewLine(writer);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 7 with AttributeDefinition

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

the class MessagingXMLWriter method writeBroadcastGroups.

private static void writeBroadcastGroups(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.BROADCAST_GROUPS.getLocalName());
        for (final Property property : properties) {
            writer.writeStartElement(Element.BROADCAST_GROUP.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
            for (AttributeDefinition attribute : BroadcastGroupDefinition.ATTRIBUTES) {
                attribute.marshallAsElement(property.getValue(), writer);
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
        writeNewLine(writer);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) Property(org.jboss.dmr.Property)

Example 8 with AttributeDefinition

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

the class MessagingXMLWriter method writeAddressSettings.

private static void writeAddressSettings(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.ADDRESS_SETTINGS.getLocalName());
        for (Property matchSetting : properties) {
            writer.writeStartElement(Element.ADDRESS_SETTING.getLocalName());
            writer.writeAttribute(Attribute.MATCH.getLocalName(), matchSetting.getName());
            final ModelNode setting = matchSetting.getValue();
            for (AttributeDefinition attribute : AddressSettingDefinition.ATTRIBUTES) {
                attribute.marshallAsElement(setting, writer);
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
        writeNewLine(writer);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 9 with AttributeDefinition

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

the class PooledConnectionFactoryAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    ModelNode model = resource.getModel();
    PathAddress address = context.getCurrentAddress();
    final String name = context.getCurrentAddressValue();
    final ModelNode resolvedModel = model.clone();
    for (final AttributeDefinition attribute : getDefinitions(PooledConnectionFactoryDefinition.ATTRIBUTES)) {
        resolvedModel.get(attribute.getName()).set(attribute.resolveModelAttribute(context, resolvedModel));
    }
    // We validated that jndiName part of the model in populateModel
    final List<String> jndiNames = new ArrayList<String>();
    for (ModelNode node : resolvedModel.get(Common.ENTRIES.getName()).asList()) {
        jndiNames.add(node.asString());
    }
    String managedConnectionPoolClassName = null;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName())) {
        managedConnectionPoolClassName = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName()).asString();
    }
    final int minPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE.getName()).asInt();
    final int maxPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE.getName()).asInt();
    Boolean enlistmentTrace = null;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName())) {
        enlistmentTrace = resolvedModel.get(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName()).asBoolean();
    }
    final String txSupport;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName())) {
        String txType = resolvedModel.get(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName()).asString();
        if (LOCAL.equals(txType)) {
            txSupport = LOCAL_TX;
        } else if (NONE.equals(txType)) {
            txSupport = NO_TX;
        } else {
            txSupport = XA_TX;
        }
    } else {
        txSupport = XA_TX;
    }
    ServiceTarget serviceTarget = context.getServiceTarget();
    List<String> connectors = Common.CONNECTORS.unwrap(context, model);
    String discoveryGroupName = getDiscoveryGroup(resolvedModel);
    String jgroupsChannelName = null;
    if (discoveryGroupName != null) {
        Resource dgResource = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address).append(CommonAttributes.DISCOVERY_GROUP, discoveryGroupName));
        ModelNode dgModel = dgResource.getModel();
        jgroupsChannelName = JGROUPS_CHANNEL.resolveModelAttribute(context, dgModel).asString();
    }
    List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(resolvedModel, context);
    final PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
    PooledConnectionFactoryService.installService(serviceTarget, name, serverAddress.getLastElement().getValue(), connectors, discoveryGroupName, jgroupsChannelName, adapterParams, jndiNames, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
    boolean statsEnabled = ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
    if (statsEnabled) {
        installStatistics(context, name);
    }
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) ArrayList(java.util.ArrayList) Resource(org.jboss.as.controller.registry.Resource) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 10 with AttributeDefinition

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

the class PooledConnectionFactoryAdd method getAdapterParams.

static List<PooledConnectionFactoryConfigProperties> getAdapterParams(ModelNode model, OperationContext context) throws OperationFailedException {
    List<PooledConnectionFactoryConfigProperties> configs = new ArrayList<PooledConnectionFactoryConfigProperties>();
    for (ConnectionFactoryAttribute nodeAttribute : PooledConnectionFactoryDefinition.ATTRIBUTES) {
        if (!nodeAttribute.isResourceAdapterProperty())
            continue;
        AttributeDefinition definition = nodeAttribute.getDefinition();
        ModelNode node = definition.resolveModelAttribute(context, model);
        if (node.isDefined()) {
            String value = node.asString();
            configs.add(new PooledConnectionFactoryConfigProperties(nodeAttribute.getPropertyName(), value, nodeAttribute.getClassType()));
        }
    }
    return configs;
}
Also used : ArrayList(java.util.ArrayList) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

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