RE: Representation<T> and Entity<T>

From: Jerome Louvel <>
Date: Tue, 10 Apr 2007 16:49:42 +0200


public MyResource {
        Foo foo; // the associated domain object

        public Document toXML() {
                // logic to generate a DOM document
                // from the current "foo" instance.

        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

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

Best regards,