Hi legege, Currently, the easiest way to customize XStream conversion is to register a custom XStreamConverter. Here are the steps:
- create a subclass of XstreamRepresentation - override the createXstream(MediaType mediaType) : XStream method - customize the XStream object using XStream aliases and so on - create a subclass of org.restlet.ext.xstream.XstreamConverter - override the create(MediaType mediaType, T source) : XstreamRepresentation method - override the create(Representation source) : XstreamRepresentation method - return your own XstreamRepresentation subclass - register your custom converter in the Engine - Engine.getInstance().getRegisteredConverters().add(0, new MyXstreamConverter()); I'm thinking about a way to customize this more easily using parameters on the ConverterService maybe. Any thought welcome. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -----Message d'origine----- De : legege [mailto:[email protected]] Envoyé : mercredi 11 novembre 2009 00:21 À : [email protected] Objet : Automatic conversion with XStream Hi, Is there a good way to change the default XStream object that will be used for automatic XML conversion? The power of Restlet 2.0 is really there, but it's really difficult to change the XStream object used in a XstreamRepresentation. Am I missing something? @Get("xml") public Patate retrieve() { return new Patate(); } The result is something similar to this <com.example.Patate> <test1 /> </com.example.Patate> Which is really not what I want. This is the expected result, with a correctly configured XStream object (with alias): <patate> <test1 /> </patate> Thanks for your help! -- View this message in context: http://n2.nabble.com/Automatic-conversion-with-XStream-tp3983313p3983313.htm l Sent from the Restlet Discuss mailing list archive at Nabble.com. ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=24163 13 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2416505

