cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: CXF fails to find a correct MessageBodyWritter for List<E> if Resource method is defined under async way
Date Mon, 15 Sep 2014 08:59:22 GMT
Hi

Thanks for raising this issue and the patch.
Unfortunately it is a won't fix issue.
It's not really related to the use of async methods but to the fact no 
type info is available in this case, the same would happen if you had 
Response with a List set on it returned.
The JAX-RS compliant way is to use GenericEntity as an entity instance 
wrapping a given collection. Give it a try please

Cheers
Sergey

On 13/09/14 08:32, iris ding wrote:
> Hi Guys,
>
> CXF fails to find a correct MessageBodyWritter for List<E> if Resource
> method is defined under async way,
> see below example, I have two methods defined, the **/collecitons can be
> returned successfully however
> we will get an error for the **/asyncCollections.
> @Path("/bookstore")
> public class BookContinuationStore {
> private final List<Book> bookList = new ArrayList<Book>();
> public BookContinuationStore()
> { init(); }
> @GET
> @Path("/collections")
> @Produces(
> { "application/xml", "application/json" })
> public List<Book> getBookCollection() throws Exception { return bookList; }
>
>
>
> @GET
> @Path("/asyncCollections")
> @Produces({ "application/xml", "application/json" }
> )
> public void getBookCollection(@Suspended AsyncResponse response) throws
> Exception
> { resumeSuspendedBookList(response); }
> private void resumeSuspendedBookList(final AsyncResponse response) {
> executor.execute(new Runnable() {
> @Override
> public void run() {
> try
> { Thread.sleep(2000); }
> catch (InterruptedException ex)
> { // ignore }
> response.resume(bookList);
> }
> });
> }
> private void init()
> { Book b1 = new Book("Iris1", 1); Book b2 = new Book("Iris2", 2);
> bookList.add(b1); bookList.add(b2); }
> }
>
> I have opened CXF-6001 for this issue and uploaded a proposed fix. Looking
> forward to your comments!
>
> Iris Ding
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-fails-to-find-a-correct-MessageBodyWritter-for-List-E-if-Resource-method-is-defined-under-async-y-tp5748709.html
> Sent from the cxf-dev mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

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

Blog: http://sberyozkin.blogspot.com

Mime
View raw message