Hi,
On 01/02/12 16:17, ceineke wrote:
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.

Custom MessageBodyReaders and Writers can get a Providers context injected and delegate to it to find the writer and reader which can actually deal with the current payload. This is the only thing that the custom provider will do, first ask the Providers instance to find a reader and writer and then delegating to the found reader/writer

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?

probably is but not at the JAX-RS level afaik...Perhaps such transformations can be hidden inside custom filters or invokers, but if it can work at the reader/writer level with the delegation to Providers then it would be the simplest way.

XSLTJaxbProvider can manages such transformations too

Cheers, Sergey

Cheers, Sergey

--
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.


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to