Search in sources :

Example 36 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class EESubsystemXmlPersister method writeManagedExecutorServices.

private void writeManagedExecutorServices(final XMLExtendedStreamWriter writer, final ModelNode subModel) throws XMLStreamException {
    writer.writeStartElement(Element.MANAGED_EXECUTOR_SERVICES.getLocalName());
    for (Property property : subModel.asPropertyList()) {
        writer.writeStartElement(Element.MANAGED_EXECUTOR_SERVICE.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
        for (SimpleAttributeDefinition ad : ManagedExecutorServiceResourceDefinition.ATTRIBUTES) {
            ad.marshallAsAttribute(property.getValue(), writer);
        }
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) Property(org.jboss.dmr.Property)

Example 37 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class EESubsystemXmlPersister method writeManagedThreadFactories.

private void writeManagedThreadFactories(final XMLExtendedStreamWriter writer, final ModelNode subModel) throws XMLStreamException {
    writer.writeStartElement(Element.MANAGED_THREAD_FACTORIES.getLocalName());
    for (Property property : subModel.asPropertyList()) {
        writer.writeStartElement(Element.MANAGED_THREAD_FACTORY.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
        for (SimpleAttributeDefinition ad : ManagedThreadFactoryResourceDefinition.ATTRIBUTES) {
            ad.marshallAsAttribute(property.getValue(), writer);
        }
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) Property(org.jboss.dmr.Property)

Example 38 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class EESubsystemXmlPersister method writeContextServices.

private void writeContextServices(final XMLExtendedStreamWriter writer, final ModelNode subModel) throws XMLStreamException {
    writer.writeStartElement(Element.CONTEXT_SERVICES.getLocalName());
    for (Property property : subModel.asPropertyList()) {
        writer.writeStartElement(Element.CONTEXT_SERVICE.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
        for (SimpleAttributeDefinition ad : ContextServiceResourceDefinition.ATTRIBUTES) {
            ad.marshallAsAttribute(property.getValue(), writer);
        }
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) Property(org.jboss.dmr.Property)

Example 39 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class RemotingProfileAdd method createChannelOptionMap.

private OptionMap createChannelOptionMap(final OperationContext context, final ModelNode channelCreationOptionsNode) throws OperationFailedException {
    final OptionMap optionMap;
    if (channelCreationOptionsNode.isDefined()) {
        final OptionMap.Builder optionMapBuilder = OptionMap.builder();
        final ClassLoader loader = this.getClass().getClassLoader();
        for (final Property optionProperty : channelCreationOptionsNode.asPropertyList()) {
            final String name = optionProperty.getName();
            final ModelNode propValueModel = optionProperty.getValue();
            final String type = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.resolveModelAttribute(context, propValueModel).asString();
            final String optionClassName = this.getClassNameForChannelOptionType(type);
            final String fullyQualifiedOptionName = optionClassName + "." + name;
            final Option option = Option.fromString(fullyQualifiedOptionName, loader);
            final String value = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.resolveModelAttribute(context, propValueModel).asString();
            optionMapBuilder.set(option, option.parseValue(value, loader));
        }
        optionMap = optionMapBuilder.getMap();
    } else {
        optionMap = OptionMap.EMPTY;
    }
    return optionMap;
}
Also used : OptionMap(org.xnio.OptionMap) Option(org.xnio.Option) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 40 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class TransformUtils method transformModel.

static ModelNode transformModel(final ModelNode legacyModel) {
    final ModelNode model = new ModelNode();
    for (Property property : legacyModel.asPropertyList()) {
        String name = property.getName();
        ModelNode legacyValue = property.getValue();
        if (legacyValue.isDefined()) {
            if (name.equals(JacORBSubsystemConstants.IOR_SETTINGS)) {
                transformIorSettings(model, legacyValue);
                continue;
            }
            final boolean expression;
            final String expressionVariable;
            if (legacyValue.getType() == ModelType.EXPRESSION) {
                expression = true;
                final Matcher matcher = Pattern.compile("\\A\\$\\{(.*):(.*)\\}\\Z").matcher(legacyValue.asExpression().getExpressionString());
                if (matcher.find()) {
                    expressionVariable = matcher.group(1);
                    String abc = matcher.group(2);
                    legacyValue = new ModelNode(abc);
                } else {
                    model.get(name).set(legacyValue);
                    continue;
                }
            } else {
                expression = false;
                expressionVariable = null;
            }
            ModelNode value;
            switch(name) {
                case JacORBSubsystemConstants.ORB_GIOP_MINOR_VERSION:
                    name = Constants.ORB_GIOP_VERSION;
                    value = new ModelNode(new StringBuilder().append("1.").append(legacyValue.asString()).toString());
                    break;
                case JacORBSubsystemConstants.ORB_INIT_TRANSACTIONS:
                    if (legacyValue.asString().equals(JacORBSubsystemConstants.ON)) {
                        value = new ModelNode(Constants.FULL);
                    } else if (legacyValue.asString().equals(JacORBSubsystemConstants.OFF)) {
                        value = new ModelNode(Constants.NONE);
                    } else {
                        value = legacyValue;
                    }
                    break;
                case JacORBSubsystemConstants.ORB_INIT_SECURITY:
                    if (legacyValue.asString().equals(JacORBSubsystemConstants.OFF)) {
                        value = new ModelNode(Constants.NONE);
                    } else {
                        value = legacyValue;
                    }
                    break;
                case JacORBSubsystemConstants.SECURITY_SUPPORT_SSL:
                case JacORBSubsystemConstants.SECURITY_ADD_COMP_VIA_INTERCEPTOR:
                case JacORBSubsystemConstants.NAMING_EXPORT_CORBALOC:
                case JacORBSubsystemConstants.INTEROP_IONA:
                    if (legacyValue.asString().equals(JacORBSubsystemConstants.ON)) {
                        value = ModelNode.TRUE;
                    } else {
                        value = ModelNode.FALSE;
                    }
                    break;
                default:
                    value = legacyValue;
            }
            if (!value.asString().equals(JacORBSubsystemConstants.OFF)) {
                if (expression) {
                    String newExpression = "${" + expressionVariable;
                    if (expressionVariable != null) {
                        newExpression += (":" + value.asString());
                    }
                    newExpression += "}";
                    value = new ModelNode(new ValueExpression(newExpression));
                }
                model.get(name).set(value);
            }
        }
    }
    if (!legacyModel.get(JacORBSubsystemConstants.ORB_SOCKET_BINDING).isDefined()) {
        model.get(JacORBSubsystemConstants.ORB_SOCKET_BINDING).set(JacORBSubsystemDefinitions.ORB_SOCKET_BINDING.getDefaultValue());
    }
    return model;
}
Also used : Matcher(java.util.regex.Matcher) ValueExpression(org.jboss.dmr.ValueExpression) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Aggregations

Property (org.jboss.dmr.Property)203 ModelNode (org.jboss.dmr.ModelNode)163 HashMap (java.util.HashMap)22 Test (org.junit.Test)19 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)16 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)16 PathAddress (org.jboss.as.controller.PathAddress)12 ArrayList (java.util.ArrayList)11 Map (java.util.Map)11 ValueExpression (org.jboss.dmr.ValueExpression)10 ModelType (org.jboss.dmr.ModelType)9 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 HashSet (java.util.HashSet)7 ArrayDeque (java.util.ArrayDeque)6 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)6 Properties (java.util.Properties)5 LinkedHashMap (java.util.LinkedHashMap)4 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 HttpResponse (org.apache.http.HttpResponse)3