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");
// Store the updates
prop.setValue(newMapValue);
getManagementView().updateComponent(component);
// Re-read the component and validate the changes took
component = getChannelFactoryManagedComponent();
prop = component.getProperty("protocolStackConfigurations");
mapValue = prop.getValue();
assertTrue(mapValue instanceof CompositeValue);
stackValue = ((CompositeValue) mapValue).get("udp-async");
assertTrue(stackValue instanceof CompositeValue);
configurationValue = ((CompositeValue) stackValue).get("configuration");
assertTrue(configurationValue instanceof CollectionValue);
protocols = ((CollectionValue) configurationValue).getElements();
udp = protocols[0];
assertTrue(udp instanceof CompositeValue);
parametersValue = ((CompositeValue) udp).get("protocolParameters");
assertTrue(parametersValue instanceof CompositeValue);
params = ((CompositeValue) parametersValue).getMetaType().keySet();
boolean sawIt = false;
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();
assertEquals(String.valueOf(maxThreads + 1), value);
sawIt = true;
break;
}
}