On Jun 8, 2010, at 5:45 PM, Johannes Schneider wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi guys,
>
> at the moment I am struggling with the conversion of my model to XML.
> While I prefer JAXB over other solutions (especially because I can add
> JSON support easily), I don't want to pollute my model with JAXB
> annotations and default constructors.
> So I am trying to create some sort of special JAXB model that is
> just a
> simple representation of my model especially made for the JAXB
> conversion. (This will also allow me to add URIs to the XML easily).
>
> Now I'd like to make the conversion from my model to the JAXB model
> happen automatically. Therefore I thought I could try a
> MessageBodyWriter.
> But of course I want to use the existing JAXB magic, too. But the
> BodyWriters cannot be wrapped easily/automatically.
>
Have you tried injecting:
@Context Providers ps;
https://jsr311.dev.java.net/nonav/releases/1.1/javax/ws/rs/ext/Providers.html
and calling:
https://jsr311.dev.java.net/nonav/releases/1.1/javax/ws/rs/ext/Providers.html
#getMessageBodyWriter%28java.lang.Class,%20java.lang.reflect.Type,
%20java.lang.annotation.Annotation[],%20javax.ws.rs.core.MediaType%29
for the type returned from bridge method?
Paul.
> So can anybody give me a hint what direction I could take?
>
>
>
> To make it clear, here a small example:
>
> Model:
> - User
>
> JAXB-Model (easily created from User using my own User2JaxbBridge):
> - JaxbUser (annotated with XmlRootElement)
>
>
> My Resource is returning a User that shall be automatically
> converted to
> a JaxbUser (using my bridge) and then automatically to XML using the
> existing JAXB stuff in Jersey...
>
>
>
> Thanks,
>
> Johannes
> - --
> Johannes Schneider - blog.cedarsoft.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQEcBAEBAgAGBQJMDmWbAAoJEAytD9R7Qv6dH+QIAJi2IeJPZwOIWQyCX2wKj3zO
> xofM3mKYuHcytACvodJUANeOi//GBGn0Lm9lIWIcQkxWX27xJGJ89JDBmPpsLqDc
> XUPn7xdgFLJynFlnl/kr1NJmTOF7y6UC0StoWPnY3bfanWoLZcpdiy3PS5BItVdx
> Ad7g11etW+Im3jGL5t1COSl/5smsdSATVdQKTMXSib5Qc4b/poTTuq7WKUDISJ94
> bmsc78F9NjRPOZmmMCSh64iMdAiPUBKdJT9p/m0uF5od3WGsbNPDByre6/P4QDV2
> MnGOMOl0c9yTpg7Jj3nSBH+lE6VZAX5uQ+2o7BSh2wzKmXfPSDWH8qLsXa8dWAo=
> =0mrX
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>