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);
}
}
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);
}
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);
}
Aggregations