On Tue, 2010-04-27 at 21:03 +0100, Eoghan Glynn wrote:
Hi Mark,
Would it be a bridge too far to also factor out a generic BaseCollection
schema type?
See for example the changes on this branch:
http://bit.ly/generic-collections
The upside is that it makes it easy to write code that walks any of the
collection types, e.g.:
http://bit.ly/abstract-action
The downside is a slight loss of type-safety, in that it would be
theoretically possible to create a VMs instance that actually contains
some Host or DataCenter objects.
Also there's a slight bloat on the wire, as the resource elements are
decorated with a xsi:type attribute to indicate the actual resource
types:
http://www.pastie.org/937952
This is what really kills it for me:
<vms>
<resource
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="VM">
<name>vm2</name>
compared to:
<vms>
<vm>
<name>vm2</name>
that just screams ugly to me, would probably be even worse in yaml/json
and generally looks like it would make things more difficult for the
simpler clients.
The only really upside I see is that it makes things a little more
generic on the server side, but I don't count that as much of an
argument.
Maybe you could use a wildcard to generalize doAction:
protected void doAction(List<? extends BaseResource>, String action) ...
Cheers,
Mark.