Hi Justin,

You are right, this is lacking documentation. I've just updated it in SVN
trunk:

"Service converting message entities into higher-level objects. As the
default implementation doesn't do any conversion by default, you have to
subclass it and update the Application's "converterService" property with
your own instance. Once this done, any Restlet or Resource that is part of
this application can easily convert from representations to objects and the
other way around. You just have to use the getEntityAsObject() method to
convert a message's representation into a higher-level object and the
setEntity(Object) method to convert a higher-level object into a
representation."

@see [EMAIL PROTECTED] org.restlet.data.Message#getEntityAsObject()}
@see [EMAIL PROTECTED] org.restlet.data.Message#setEntity(Object)}

It seems indeed like this service would help you to centralize your
conversion logic. But nothing is done automatically, you still need to
manually call getEntityAsObject() or setEntity(Object) methods in order to
trigger the converter service.

Best regards,
Jerome  

> -----Message d'origine-----
> De : Justin Makeig [mailto:[EMAIL PROTECTED] 
> Envoyé : jeudi 20 septembre 2007 02:09
> À : [email protected]
> Objet : ConverterService
> 
> There are a couple discussion threads about the ConverterService  
> (http://www.mail-archive.com/[email protected]/ 
> msg01773.html), but I still don't understand its advantages 
> or how to  
> implement it. I find myself writing the same type of code in the  
> getRepresentation methods for all of my resources to expose them as  
> HTML, JSON, and XML. Would the converter service simplify/centralize  
> this? What about handling metadata (for example when building 
> an HTML  
> representation) beyond just the raw entity that's being serialized?  
> Could I use the ConverterService in concert with Resource-level  
> representation handling? For example to serialize/deserialize JSON  
> and XML generically, but define HTML representations at the resource  
> level. Any help would be greatly appreciated.
> 
> Justin

Reply via email to