Hi Charles


Many thanks.

I camel project, I have designed a new dataformat component which allows to
bind non XML format into POJOs using annotations
(http://camel.apapche.org/bindy.html). Using marshaling/unmarshaling methods
of camel, we can transform the content of a stream into POJO or vice versa.

I'm very interested to adapt camel bindy in order to add it as message body
writer / reader in CXF JAX-RS. This will allow to send a text/plain message
containing CSV text or Key value Pair (ex FIX messages) and map it to their
POJOs or from POJOS, generate the text which is send back to the API Calling
JAX-RS.

sounds good


Can you provide more info about creating message body writer / reader in CXF
JAX-RS ?

Please have a look here :

http://cwiki.apache.org/CXF20DOC/jax-rs.html#JAX-RS-MessageBodyProviders

For ex, a custom BindyProvider can implement both MessageBodyReader and 
MessageBodyWriter.
It should be ok for a start just to have "true" returned from 
isReadable/isWriteable and -1 from getSize().


Next, in writeTo/readFrom, you can check Annotation[]  for expected Bindy 
annotations and proceed from there.
You might want to use CXF specifc AnnotationUtils.

In writeTo, it is method level annotations which are passed in, ex, they'll 
contain @GET and @BindySpecific if we have a method like

@GET
@BindySpecific
SomeObject getObject()

while in readFrom it is annotations attached to a given method parameter, ex, 
@BindySpecific will be passed in this case

@POST
void post(@BindySpecific SomeObject)

in writeTo()/readFrom, you can also check the annotation on the actual 
SomeObject class

hope it gives some starting info, let me know please if more info is needed

cheers, Sergey


Regards,

Charles


Sergey Beryozkin-2 wrote:

Hi Charles

I agree, would be worth listing explicitly the types which are supported
out of the box.
I believe the only media types which JAXRS requires to support are
1. application/xml, application/*+xml and text/xml assuming JAXB or JAXP
Source is used
2. application/octet-stream for types like InputStream
3. text/plain for String

Probably all the JAXRS implementations support application/json, in CXF
case it is a JAXB-based Jettison provider which does it.
Users can register custom providers for handling application/xml,
application/json, etc (ex, Jackson for JSON, XmlBeans or Aegis for
XML, etc).

CXF ships providers for handling application/atom+xml, multipart/*, as
well as providers such as XSLTJaxbProvider and
RequestDispatchProvider which facilitate the creation of xml or html based
data. XSLTJaxbProvider alone can be used to produce any
type of format...though it's obviously restricted to consuming xml-based
data only

Hope it  helps, Sergey


Hi,

Is there somewhere a document describing which mime-type have been
implemented by default in CXF for JAX-RS ?

ex :  application/xml, application/xhtml+xml, application/json, ...

Regards,

Charles

-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/
http://cmoulliard.blogspot.com/
--
View this message in context:
http://old.nabble.com/%40Produce---MIME-TYPE-implemented-in-CXF-JAXRS-tp26541657p26541657.html
Sent from the cxf-user mailing list archive at Nabble.com.






-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
--
View this message in context: 
http://old.nabble.com/%40Produce---MIME-TYPE-implemented-in-CXF-JAXRS-tp26541657p26542270.html
Sent from the cxf-user mailing list archive at Nabble.com.


Reply via email to