cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ceineke <chris.ein...@ek3.com>
Subject JAX-RS: Convert return value to JAXB-annotated element for transparent marshalling
Date Wed, 01 Feb 2012 16:17:42 GMT
My service contains a facade object that accepts and returns domain objects
which are POJOs. I've created an XSD for my JAX-RS service that specifies
the incoming and outgoing data types and refer to in the
<jaxrs:schemaLocations> section.

Unfortunately I have to litter my service implementation with methods like
"convertToDomainObject(TransferObject from)" and
"convertToTransferObject(DomainObject from)", because there is no straight
1-to-1 attribute mapping between the POJOs and the TOs (eg. integer are
reduced to booleans and vice-versa).

I looked at MessageBodyReader/MessageBodyWriter to convert between the two,
but implementing these providers doesn't seem to be the right approach to
me. I pull in the JacksonJsonProvider to gain transparent JSON support, but
with the readers/writers I would have to explicitly check the HTTP content
type and do the serialization to the requested type myself.

Basically, is there a way to map from instances of non-JAXB classes to
instances of JAXB-annotated classes without going as low as
MessageBodyReaderS and MessageBodyWriterS?

--
View this message in context: http://cxf.547215.n5.nabble.com/JAX-RS-Convert-return-value-to-JAXB-annotated-element-for-transparent-marshalling-tp5447971p5447971.html
Sent from the cxf-user mailing list archive at Nabble.com.

Mime
View raw message