Marc,
@Resource
public MyResource {
Foo foo; // the associated domain object
@Output("application/foo-xml")
public Document toXML() {
// logic to generate a DOM document
// from the current "foo" instance.
}
@Output("application/foo-json")
public JSONObject toJSON() {
// logic to generate a JSON object
// from the current "foo" instance.
}
}
> Is the above meant to be a resource class or a representation
> ? I.e.
> are the toXML and toJSON methods meant to respond directly to a HTTP
> GET or is there another class that does that and returns an instance
> of the above ?
It is meant to be the resource POJO. It is one way to design this, which is
interesting when the wrapped domain object ("foo" member here) isn't
annotable.
I have changed the @Representation annotations to the more explicit @Output
ones. The JSR implementation should compare the representation variants
available and select the best one based on the client preferences (content
negotiation).
Best regards,
Jerome