Thank you for the quick reply. This certainly would resolve the issue but it
doesn't really offer the kind of solution I was hoping for. With this
solution i'd still have to do a mapping of media type to some representation
which is what I am trying to avoid. The thought was that there is a
Representation that just outputs the message body regardless of whatever
media type variant is set for it. That way I don't have to make a mapping of
media type to anything.

On Fri, Jan 22, 2010 at 1:27 PM, Matt Kennedy <[email protected]> wrote:

> I can't remember what 1.1.6's API looks like, but I do something like this
> with the 2.0 API.  Basically, in the Resource's constructor, I use someting
> like:
>
> getVariants().add(new MyXMLRepresentation(this))
> getVariants().add(new MyJSONRepresentation(this))
>
>
> Each of those My* classes are a subclass of Representation, and the write()
> method is overridden to produce the custom media type.  I pass the Resource
> object to the custom representation so that I have access to the resource
> during the write method.  Also important is that in the constructor, you
> call the super constructor with the MediaType and resource as arguments, ex:
>
> //Constructor
> public MyJSONRepresentation(Resource res)
> {
>  super(MediaType.APPLICATION_JSON, res);
> }
>
> I know something like this can be done with the 1.1.6 API because I was
> using it before I ported to 2.0, but now I can't find the 1.1.6 code. It
> probably isn't too different.
>
> On Jan 22, 2010, at 3:50 PM, Jean-Philippe Steinmetz wrote:
>
> > Hello all,
> >
> > We're using restlet 1.1.6 and for all our resources we want to support a
> dynamic set of media types. We do this in our Spring configuration by
> setting up a list of acceptable media types. My question is if there is a
> Representation class I can use that will essentially accept any type of data
> I push into it? For instance we support HTML, XML, JSON and AMF3 therefore
> most of the time it's a string based representation but in the case of AMF3
> it is binary (byte array). So far the only way I see it is to make a switch
> statement in our resource class for each media type but this pretty much
> defeats the purpose of specifying supported media types in the application
> configuration.
> >
> > Jean-Philippe
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2441312
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2441339

Reply via email to