[jboss-cvs] JBossAS SVN: r90502 - in branches/dml-log-service-integration: testsuite/src/main/org/jboss/test/cluster/channelfactory/managed and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 22 13:04:50 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-06-22 13:04:50 -0400 (Mon, 22 Jun 2009)
New Revision: 90502
Modified:
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java
Log:
Merge from trunk: -r90480:90501
Modified: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java 2009-06-22 16:02:42 UTC (rev 90501)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java 2009-06-22 17:04:50 UTC (rev 90502)
@@ -31,12 +31,14 @@
import org.jboss.metatype.api.types.CollectionMetaType;
import org.jboss.metatype.api.types.CompositeMetaType;
import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.CollectionValue;
import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
@@ -55,25 +57,22 @@
public class ProtocolStackConfigMapper extends MetaMapper<ProtocolData[]>
{
public static final CompositeMetaType PROTOCOL_PARAMETER_TYPE;
- public static final CollectionMetaType PROTOCOL_PARAMETER_SET_TYPE;
+ public static final CompositeMetaType PROTOCOL_PARAMETER_MAP_TYPE;
public static final CompositeMetaType PROTOCOL_STACK_CONFIG_TYPE;
public static final CollectionMetaType TYPE;
static
{
String[] paramItemNames = {
- "name",
"description",
"value"
};
String[] paramItemDescs = {
- "the name of the configuration parameter",
"description of the meaning of the attribute",
"the value of the configuration parameter"
};
MetaType[] paramItemTypes = {
SimpleMetaType.STRING,
- SimpleMetaType.STRING,
SimpleMetaType.STRING
};
@@ -81,8 +80,10 @@
"Protocol Parameters",
paramItemNames, paramItemDescs, paramItemTypes);
- PROTOCOL_PARAMETER_SET_TYPE = new CollectionMetaType(Set.class.getName(), PROTOCOL_PARAMETER_TYPE);
+// PROTOCOL_PARAMETER_MAP_TYPE = new CollectionMetaType(Set.class.getName(), PROTOCOL_PARAMETER_TYPE);
+ PROTOCOL_PARAMETER_MAP_TYPE = new MapCompositeMetaType(PROTOCOL_PARAMETER_TYPE);
+
String[] configItemNames = {
"name",
"description",
@@ -100,7 +101,7 @@
SimpleMetaType.STRING,
SimpleMetaType.STRING,
SimpleMetaType.STRING,
- PROTOCOL_PARAMETER_SET_TYPE
+ PROTOCOL_PARAMETER_MAP_TYPE
};
@@ -134,22 +135,23 @@
protocolValue.put("description", SimpleValueSupport.wrap(data[i].getDescription()));
protocolValue.put("className", SimpleValueSupport.wrap(data[i].getClassName()));
- ProtocolParameter[] params = data[i].getParametersAsArray();
- MetaValue[] paramElements = new MetaValue[params.length];
+ ProtocolParameter[] params = data[i].getParametersAsArray();
+ Map<String, MetaValue> paramValues = new HashMap<String, MetaValue>();
+// MetaValue[] paramElements = new MetaValue[params.length];
for (int j = 0; j < params.length; j++)
{
Map<String, MetaValue> paramValue = new HashMap<String, MetaValue>();
- paramValue.put("name", SimpleValueSupport.wrap(params[j].getName()));
+// paramValue.put("name", SimpleValueSupport.wrap(params[j].getName()));
// FIXME -- deal with description
// protocolValue.put("description", SimpleValueSupport.wrap(params[j].getDescription()));
// paramValue.put("description", null);
paramValue.put("value", SimpleValueSupport.wrap(params[j].getValue()));
- paramElements[j] = new CompositeValueSupport(PROTOCOL_PARAMETER_TYPE, paramValue);
+ paramValues.put(params[j].getName(), new CompositeValueSupport(PROTOCOL_PARAMETER_TYPE, paramValue));
}
- protocolValue.put("protocolParameters", new CollectionValueSupport(PROTOCOL_PARAMETER_SET_TYPE, paramElements));
+ protocolValue.put("protocolParameters", new MapCompositeValueSupport(paramValues, PROTOCOL_PARAMETER_MAP_TYPE));
- dataElements[i] = new CompositeValueSupport(PROTOCOL_STACK_CONFIG_TYPE, protocolValue);
+ dataElements[i] = new MapCompositeValueSupport(protocolValue, PROTOCOL_STACK_CONFIG_TYPE);
}
return new CollectionValueSupport(TYPE, dataElements);
}
@@ -175,15 +177,16 @@
String protName = (String) ((SimpleValue) protocolValue.get("name")).getValue();
String protDesc = (String) ((SimpleValue) protocolValue.get("description")).getValue();
String protClass = (String) ((SimpleValue) protocolValue.get("className")).getValue();
- CollectionValue paramsValue = (CollectionValue) protocolValue.get("protocolParameters");
- MetaValue[] paramElements = paramsValue.getElements();
- ProtocolParameter[] protParams = paramElements == null ? null : new ProtocolParameter[paramElements.length];
- for (int j = 0 ; j < paramElements.length; j++)
+ CompositeValue paramsValue = (CompositeValue) protocolValue.get("protocolParameters");
+ Set<String> paramNames = paramsValue.getMetaType().keySet();
+ ProtocolParameter[] protParams = new ProtocolParameter[paramNames.size()];
+ int j = 0;
+ for (String paramName : paramNames)
{
- CompositeValue paramValue = (CompositeValue) paramElements[j];
- String paramName = (String) ((SimpleValue) paramValue.get("name")).getValue();
+ CompositeValue paramValue = (CompositeValue) paramsValue.get(paramName);
String paramVal = (String) ((SimpleValue) paramValue.get("value")).getValue();
- protParams[j] = new ProtocolParameter(paramName, paramVal);
+ protParams[j] = new ProtocolParameter(paramName, paramVal);
+ j++;
}
protocolData[i] = new ProtocolData(protName, protDesc, protClass, protParams);
}
Modified: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java 2009-06-22 16:02:42 UTC (rev 90501)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java 2009-06-22 17:04:50 UTC (rev 90502)
@@ -121,12 +121,13 @@
}
assertNotNull(getSimpleValue(compVal, "className", String.class));
MetaValue mv = compVal.get("protocolParameters");
- assertTrue(mv instanceof CollectionValue);
- CollectionValue params = (CollectionValue) mv;
- MetaValue[] elements = params.getElements();
- for (MetaValue element : elements)
+ assertNotNull(mv);
+ assertTrue(mv + " (" + mv.getClass().getSimpleName() + ") is a CompositeValue", mv instanceof CompositeValue);
+ CompositeValue params = (CompositeValue) mv;
+// MetaValue[] elements = params.getElements();
+ for (String paramName : params.getMetaType().keySet())
{
- validateProtocolParameter(element);
+ validateProtocolParameter(params.get(paramName));
}
}
@@ -135,7 +136,7 @@
assertNotNull("null protocol parameter", metaValue);
assertTrue(metaValue instanceof CompositeValue);
CompositeValue compVal = (CompositeValue) metaValue;
- assertNotNull(getSimpleValue(compVal, "name", String.class));
+// assertNotNull(getSimpleValue(compVal, "name", String.class));
Object val = getSimpleValue(compVal, "description");
if (val != null)
{
Modified: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java 2009-06-22 16:02:42 UTC (rev 90501)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java 2009-06-22 17:04:50 UTC (rev 90502)
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -184,28 +185,26 @@
MetaValue udp = protocols[0];
assertTrue(udp instanceof CompositeValue);
MetaValue parametersValue = ((CompositeValue) udp).get("protocolParameters");
- assertTrue(parametersValue instanceof CollectionValue);
- MetaValue[] params = ((CollectionValue) parametersValue).getElements();
- boolean updated = false;
+ assertTrue(parametersValue instanceof CompositeValue);
+ Set<String> params = ((CompositeValue) parametersValue).getMetaType().keySet();
int maxThreads = -1;
- for (int i = 0; i < params.length; i++)
- {
- CompositeValue param = (CompositeValue) params[i];
- String name = (String) ((SimpleValue) param.get("name")).getValue();
+ 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);
- MapCompositeValueSupport newVal = cloneCompositeValue(param);
+ newVal = cloneCompositeValue(param);
newVal.put("value", SimpleValueSupport.wrap(String.valueOf(maxThreads + 1)));
- params[i] = newVal;
- updated = true;
break;
}
}
- assertTrue("updated max_threads config", updated);
+ assertNotNull("updated max_threads config", newVal);
- CollectionValue newParametersValue = new CollectionValueSupport(((CollectionValue) parametersValue).getMetaType(), params);
+ 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;
@@ -242,19 +241,22 @@
udp = protocols[0];
assertTrue(udp instanceof CompositeValue);
parametersValue = ((CompositeValue) udp).get("protocolParameters");
- assertTrue(parametersValue instanceof CollectionValue);
- params = ((CollectionValue) parametersValue).getElements();
- for (int i = 0; i < params.length; i++)
+ assertTrue(parametersValue instanceof CompositeValue);
+ params = ((CompositeValue) parametersValue).getMetaType().keySet();
+ boolean sawIt = false;
+ for (String name : params)
{
- CompositeValue param = (CompositeValue) params[i];
- String name = (String) ((SimpleValue) param.get("name")).getValue();
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;
}
}
+ assertTrue(sawIt);
assertTrue(((CompositeValue) mapValue).containsKey("new-stack"));
assertFalse(((CompositeValue) mapValue).containsKey("tcp-async"));
More information about the jboss-cvs-commits
mailing list