Search in sources :

Example 16 with ValueExpression

use of org.jboss.dmr.ValueExpression in project eap-additional-testsuite by jboss-set.

the class ExpressionSupportSmokeTestCase method handleComplexItem.

private void handleComplexItem(PathAddress address, String attrName, ModelNode item, ModelNode valueTypeDesc, ModelNode updatedItem, ModelNode itemToExpect) {
    // Hack to deal with time unit processing
    Set<String> keys = valueTypeDesc.keys();
    boolean timeAttr = keys.size() == 2 && keys.contains("time") && keys.contains("unit");
    boolean changed = false;
    for (Property fieldProp : valueTypeDesc.asPropertyList()) {
        String fieldName = fieldProp.getName();
        if (!item.has(fieldName)) {
            continue;
        }
        boolean timeunit = timeAttr && "unit".equals(fieldName);
        ModelNode fieldDesc = fieldProp.getValue();
        ModelNode fieldValue = item.get(fieldName);
        ModelType valueType = fieldValue.getType();
        if (valueType == ModelType.UNDEFINED || valueType == ModelType.EXPRESSION || // too complex
        COMPLEX_TYPES.contains(valueType) || !fieldDesc.get(EXPRESSIONS_ALLOWED).asBoolean(false)) {
            updatedItem.get(fieldName).set(fieldValue);
            itemToExpect.get(fieldName).set(fieldValue);
        } else {
            if (valueType == ModelType.STRING) {
                checkForUnconvertedExpression(address, attrName, item);
            }
            String valueString = timeunit ? fieldValue.asString().toLowerCase() : fieldValue.asString();
            String expression = "${exp.test:" + valueString + "}";
            updatedItem.get(fieldName).set(expression);
            itemToExpect.get(fieldName).set(new ModelNode().set(new ValueExpression(expression)));
            changed = true;
        }
    }
    if (!changed) {
        // Use unchanged 'item'
        updatedItem.set(item);
        itemToExpect.set(item);
    }
}
Also used : ValueExpression(org.jboss.dmr.ValueExpression) ModelType(org.jboss.dmr.ModelType) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 17 with ValueExpression

use of org.jboss.dmr.ValueExpression in project wildfly-swarm by wildfly-swarm.

the class SocketBindingGroupMarshaller method configureSocketBinding.

private void configureSocketBinding(PathAddress address, OutboundSocketBinding binding, List<ModelNode> list) {
    ModelNode node = new ModelNode();
    node.get(OP_ADDR).set(address.append("remote-destination-outbound-socket-binding", binding.name()).toModelNode());
    node.get(OP).set(ADD);
    node.get(HOST).set(new ValueExpression(binding.remoteHostExpression()));
    node.get(PORT).set(new ValueExpression(binding.remotePortExpression()));
    list.add(node);
}
Also used : ValueExpression(org.jboss.dmr.ValueExpression) ModelNode(org.jboss.dmr.ModelNode)

Example 18 with ValueExpression

use of org.jboss.dmr.ValueExpression in project wildfly-swarm by wildfly-swarm.

the class SocketBindingGroupMarshaller method configureSocketBinding.

private void configureSocketBinding(PathAddress address, SocketBinding binding, List<ModelNode> list) {
    ModelNode node = new ModelNode();
    node.get(OP_ADDR).set(address.append("socket-binding", binding.name()).toModelNode());
    node.get(OP).set(ADD);
    node.get(PORT).set(new ValueExpression(binding.portExpression()));
    if (binding.iface() != null) {
        node.get(INTERFACE).set(binding.iface());
    }
    if (binding.multicastAddress() != null) {
        node.get(MULTICAST_ADDRESS).set(binding.multicastAddress());
    }
    if (binding.multicastPortExpression() != null) {
        node.get(MULTICAST_PORT).set(new ValueExpression(binding.multicastPortExpression()));
    }
    list.add(node);
}
Also used : ValueExpression(org.jboss.dmr.ValueExpression) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ModelNode (org.jboss.dmr.ModelNode)18 ValueExpression (org.jboss.dmr.ValueExpression)18 Property (org.jboss.dmr.Property)10 ModelType (org.jboss.dmr.ModelType)9 HashSet (java.util.HashSet)3 Test (org.junit.Test)3 PathAddress (org.jboss.as.controller.PathAddress)2 Configuration (io.jaegertracing.Configuration)1 LinkedList (java.util.LinkedList)1 Matcher (java.util.regex.Matcher)1 OutboundSocketBinding (org.wildfly.swarm.spi.api.OutboundSocketBinding)1 SocketBinding (org.wildfly.swarm.spi.api.SocketBinding)1 SocketBindingGroup (org.wildfly.swarm.spi.api.SocketBindingGroup)1