On 27 Jul 2007, at 18:32, Adam Taft wrote:
Maybe you have a good reason to create all your representations in
the constructor of the Resource?
To avoid the boring
if (myvariant1.includes(v) {
..
} { else if (myvariant2.includes(v) {
..
} ...
dance you can put the representations straight into getVariants().
See http://restlet.tigris.org/issues/show_bug.cgi?id=303 for the
enhancement request.
We are using this approach:
- having some kind of Map to a set of inner classes of the Resource
(that
implement some Representation-ish interface) could be a way, that way
they could
all access shared state of the resource (ie. the bean loaded from the
database,
security/sanity checks, etc), yet be separate methods that can be
invoked
manually (say by one resource including the other). [suggested by
Stian Soiland]
We might be able to integrate our code into Restlet, currently for
inspiration feel free to look at (LGPL licensed code):
http://taverna.cvs.sourceforge.net/taverna/taverna-service/taverna-
rest/src/main/java/net/sf/taverna/service/rest/resources/
AbstractResource.java?revision=1.19&view=markup
http://taverna.cvs.sourceforge.net/taverna/taverna-service/taverna-
rest/src/main/java/net/sf/taverna/service/rest/resources/representation/
and example usage, including velocity template:
http://taverna.cvs.sourceforge.net/taverna/taverna-service/taverna-
rest/src/main/java/net/sf/taverna/service/rest/resources/
UserResource.java?view=markup
--
Stian Soiland, myGrid team
School of Computer Science
The University of Manchester
http://www.cs.man.ac.uk/~ssoiland/