Hi Sanjay,

 

There is no converter helper for JAXB yet. This is planned for Restlet 2.0 M5. 
You can track this RFE:

 

“Upgrade extensions to use Restlet 2.0 APIs”

http://restlet.tigris.org/issues/show_bug.cgi?id=855

 

If you want to contribute a JaxbConverter, that would be very welcome. You can 
look at the XmlConverter class in the org.restlet.ext.xml extension for 
guidance.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~  <http://www.restlet.org/> 
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  <http://www.noelios.com/> 
http://www.noelios.com

 

 

 

De : Sanjay Acharya [mailto:[email protected]] 
Envoyé : samedi 15 août 2009 18:14
À : [email protected]
Objet : Restlet 2.0 Jaxb Question

 

I am trying to work with the annotation based approach in Restlet using Jaxb 
for XML binding. One of my goals to keep the code more consice than what I 
would have done with Restlet 1.0.


@XmlRootEntity
public class Foo {
   ....
}


@XmlRootEntity
public class FooResponse {
   ....
}

1. Expect and Return Jaxb Objects
@Post("xml:xml")
public FooResponse createFoo(Foo foo) {
}

The above signature is similar to how a Post would be handled in JaxRS. I 
however do not find automatic conversion of the XML payload into Foo. 

2. Accept and Return JaxbRepresentations
@Post("xml:xml")
public JaxbRepresentation<FooResponse> createFoo(JaxbRepresentation<Foo> rep) {
   ...
}

With the above method as well, the argument to the method appears as null.
It appears that the Converter Service is not finding a match for  converting 
the xml payload into a JaxbRepresentation or Foo

3. Accept Representation
@Post("xml:xml")
public JaxbRepresentation<FooResponse> createFoo(Representation rep) {
     JaxbRepresentation fooJaxbRep = new JaxbRepresentation(rep, Foo.class);
    ...
    ...
    return new JaxbRepresentation<FooResponse>(...);
}

The above solution works for me. However, there are too many steps that I need 
to write to get the JAXB object and provide a response. 
If I decide that I would like to use JAXB through out my entire application, do 
I need to extend and register a Custom Converter service to achieve either 
option 1 or option 2? 

Thanks in advance.



  _____  

Windows Live: Keep your life in sync. Check it out. 
<http://windowslive.com/explore?ocid=PID23384::T:WLMTAGL:ON:WL:en-US:NF_BR_sync:082009>

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

Reply via email to