assertTrue(udp instanceof CompositeValue);
MetaValue parametersValue = ((CompositeValue) udp).get("protocolParameters");
assertTrue(parametersValue instanceof CompositeValue);
Set<String> params = ((CompositeValue) parametersValue).getMetaType().keySet();
int maxThreads = -1;
MapCompositeValueSupport newVal = null;
for (String name : params)
{
if ("oob_thread_pool.max_threads".equals(name))
{
CompositeValue param = (CompositeValue) ((CompositeValue) parametersValue).get(name);
String value = (String) ((SimpleValue) param.get("value")).getValue();
maxThreads = Integer.parseInt(value);
newVal = cloneCompositeValue(param);
newVal.put("value", SimpleValueSupport.wrap(String.valueOf(maxThreads + 1)));
break;
}
}
assertNotNull("updated max_threads config", newVal);
MapCompositeValueSupport newParametersValue = cloneCompositeValue((CompositeValue) parametersValue);
newParametersValue.put("oob_thread_pool.max_threads", newVal);
MapCompositeValueSupport newUdp = cloneCompositeValue((CompositeValue) udp);
newUdp.put("protocolParameters", newParametersValue);
protocols[0] = newUdp;
CollectionValue newConfigurationValue =
new CollectionValueSupport(((CollectionValue) configurationValue).getMetaType(), protocols);
MapCompositeValueSupport updatedStack = cloneCompositeValue((CompositeValue) stackValue);
updatedStack.put("configuration", newConfigurationValue);
MapCompositeValueSupport newMapValue = cloneCompositeValue((CompositeValue) mapValue);
newMapValue.put("udp-async", updatedStack);
// Add a stack
MapCompositeValueSupport newStack = cloneCompositeValue((CompositeValue) stackValue);
newStack.put("name", SimpleValueSupport.wrap("new-stack"));
newMapValue.put("new-stack", newStack);
// Remove a stack
newMapValue.remove("tcp-async");