For jboss-as-threads I wrote pretty full model descriptors, however for values such as
<keepalive-time time="100" unit="ms"/>
I split this into two attributes in the model
node.get(ATTRIBUTES, KEEPALIVE_TIME_DURATION,
DESCRIPTION).set(bundle.getString("threadpool.common.keepaliveduration"));
node.get(ATTRIBUTES, KEEPALIVE_TIME_DURATION, TYPE).set(ModelType.LONG);
node.get(ATTRIBUTES, KEEPALIVE_TIME_DURATION, REQUIRED).set(false);
node.get(ATTRIBUTES, KEEPALIVE_TIME_UNIT,
DESCRIPTION).set(bundle.getString("threadpool.common.keepaliveunit"));
node.get(ATTRIBUTES, KEEPALIVE_TIME_UNIT, TYPE).set(ModelType.STRING);
node.get(ATTRIBUTES, KEEPALIVE_TIME_UNIT, REQUIRED).set(false);
//threadpool.common.keepaliveduration=Used to specify the amount of time that pool threads
should be kept running when idle; if not specified, threads will run until the executor is
shut down.
//threadpool.common.keepaliveunit=The time unit for the number specified in
keepalive-time-duration.
Working on the marshalling I see Emanuel takes a different approch by passing in simple
sub-elements like this as a ModelNode which is more elegant. That is kind of what I wanted
to do but didn't really know how to write the description in a nice way. Since there
are not many descriptors yet I'd like to clarify the structure and find the best
practice. My original thought was that the structure would have to go in the node's
description attribute (ATTRIBUTES, KEEPALIVE_TIME, DESCRIPTION below), but it might be
nicer to do something like this:
node.get(ATTRIBUTES, KEEPALIVE_TIME, DESCRIPTION).set("Used to specify the
amount of time that pool threads should be kept running when idle; if not specified,
threads will run until the executor is shut down"));
node.get(ATTRIBUTES, KEEPALIVE_TIME, TYPE).set(ModelType.OBJECT);
node.get(ATTRIBUTES, KEEPALIVE_TIME, REQUIRED).set(false);
node.get(ATTRIBUTES, KEEPALIVE_TIME, TIME, DESCRIPTION).set("The
time"));
node.get(ATTRIBUTES, KEEPALIVE_TIME, TIME, TYPE).set(ModelType.LONG);
node.get(ATTRIBUTES, KEEPALIVE_TIME, TIME, REQUIRED).set(false);
node.get(ATTRIBUTES, KEEPALIVE_TIME, UNIT, DESCRIPTION).set("The time unit
(Seconds, Milliseconds etc.)"));
node.get(ATTRIBUTES, KEEPALIVE_TIME, UNIT, TYPE).set(ModelType.STRING);
node.get(ATTRIBUTES, KEEPALIVE_TIME, UNIT, REQUIRED).set(false);
And if the keepalive-time attribute is optional but if present both time and unit
sub-attributes must be specified, I think we would go with something like
node.get(ATTRIBUTES, KEEPALIVE_TIME, REQUIRED).set(false);
node.get(ATTRIBUTES, KEEPALIVE_TIME, TIME, REQUIRED).set(true);
node.get(ATTRIBUTES, KEEPALIVE_TIME, UNIT, REQUIRED).set(true);
If it is keepalive-time is required and unit is optional, how about
node.get(ATTRIBUTES, KEEPALIVE_TIME, REQUIRED).set(true);
node.get(ATTRIBUTES, KEEPALIVE_TIME, TIME, REQUIRED).set(true);
node.get(ATTRIBUTES, KEEPALIVE_TIME, UNIT, REQUIRED).set(false);